Commit 8b073f2b authored by julescournut's avatar julescournut
Browse files

Hot Fixes

parent d6032de9
......@@ -34,6 +34,11 @@ namespace BusinessLayer
return DalManager.FightsList();
}
public List<War> WarList()
{
return DalManager.WarList();
}
public Character getCharacterById(int id)
{
return DalManager.getCharacterById(id);
......
......@@ -92,6 +92,11 @@ namespace DataAccessLayer
return dataBaseBridge.TerritoriesList();
}
public List<War> WarList()
{
return dataBaseBridge.WarList();
}
public int addCharacter(Character character)
{
return dataBaseBridge.addCharacter(character);
......
......@@ -11,10 +11,12 @@ namespace DataAccessLayer
{
List<House> HousesList();
List<House> HousesList(int sup);
Dictionary<Character, RelationshipType> RelationShipList(int id);
List<Character> CharactersList();
List<Characteristics> CharactersCharacteristicsList();
List<Territory> TerritoriesList();
List<Fight> FightsList();
List<War> WarList();
Character getCharacterById(int id);
House getHouseById(int id);
......
......@@ -68,6 +68,31 @@ namespace DataAccessLayer
return result;
}
public Dictionary<Character, RelationshipType> RelationShipList(int id)
{
Dictionary<Character, RelationshipType> res = new Dictionary<Character, RelationshipType>();
try
{
DataTable dataTable = SelectByDataAdapter("Select * From Relationship Where id_charach1 = " + id + " OR id_charach2 = " + id);
foreach (DataRow row in dataTable.Rows)
{
int id_character = Convert.ToInt32(row["id_charach1"]);
if (id_character == id)
{
id_character = Convert.ToInt32(row["id_charach2"]);
}
Character character = getCharacterById(id_character);
res.Add(character, (RelationshipType)Convert.ToInt32(row["type"]));
}
}
catch (Exception e)
{
LogException(e);
}
return res;
}
public List<Character> CharactersList()
{
List<Character> res = new List<Character>();
......@@ -78,8 +103,8 @@ namespace DataAccessLayer
foreach (DataRow row in dataTable.Rows)
{
int id_house = Convert.ToInt32(row["id_house"]);
House house = getHouseById(id_house); ;
Character character = new Character(Convert.ToInt32(row["Id"]), row["FirstName"].ToString(), row["LastName"].ToString(), Convert.ToUInt32(row["PV"]), (CharacterType)Convert.ToInt32(row["Type"]), Convert.ToInt32(row["Bravoury"]), Convert.ToInt32(row["Crazyness"]), house);
House house = getHouseById(id_house);
Character character = new Character(Convert.ToInt32(row["Id"]), row["FirstName"].ToString(), row["LastName"].ToString(), Convert.ToUInt32(row["PV"]), (CharacterType)Convert.ToInt32(row["Type"]), Convert.ToInt32(row["Bravoury"]), Convert.ToInt32(row["Crazyness"]), house/*, RelationShipList(Convert.ToInt32(row["Id"]))*/);
res.Add(character);
}
}
......@@ -165,6 +190,19 @@ namespace DataAccessLayer
}
return res;
}
public List<War> WarList()
{
List<War> res = new List<War>();
DataTable dataTable = SelectByDataAdapter("Select * From War");
foreach (DataRow row in dataTable.Rows)
{
War war = new War(Convert.ToInt32(row["Id"]), row["name"].ToString());
res.Add(war);
}
return res;
}
public House getHouseById(int id)
{
House res = null;
......
No preview for this file type
No preview for this file type
......@@ -6,14 +6,6 @@ using System.Threading.Tasks;
namespace EntitiesLayer
{
public enum RelationshipType
{
FRIENDSHIP,
LOVE,
HATRED,
RIVALRY
}
public enum CharacterType
{
WARRIOR,
......
......@@ -46,6 +46,7 @@
<Compile Include="Fight.cs" />
<Compile Include="House.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="RelationShip.cs" />
<Compile Include="Territory.cs" />
<Compile Include="War.cs" />
</ItemGroup>
......
......@@ -282,6 +282,8 @@
<Content Include="Views\Character\Create.cshtml" />
<Content Include="Views\House\Index.cshtml" />
<Content Include="Views\Fight\Index.cshtml" />
<Content Include="Views\War\Index.cshtml" />
<Content Include="Views\Territory\Index.cshtml" />
</ItemGroup>
<ItemGroup>
<Folder Include="App_Data\" />
......
......@@ -3,8 +3,6 @@ using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace MVC.Models
{
public enum RelationshipType
......@@ -23,19 +21,19 @@ namespace MVC.Models
LEADER,
LOSER
}
public class Characteristics
public class CharacteristicsModels
{
public uint PV { get; set; }
public CharacterType Type { get; set; }
public int Bravoury { get; set; }
public int Crazyness { get; set; }
public Characteristics()
public CharacteristicsModels()
{
}
public Characteristics(uint pv, CharacterType type, int bravoury, int crazyness)
public CharacteristicsModels(uint pv, CharacterType type, int bravoury, int crazyness)
{
PV = pv;
Type = type;
......@@ -54,7 +52,7 @@ namespace MVC.Models
public string FirstName { get; set; }
public string LastName { get; set; }
public HouseModels House { get; set; }
public Characteristics Characteristics { get; set; }
public CharacteristicsModels Characteristics { get; set; }
public Dictionary<CharacterModels, RelationshipType> RelationShips { get; set; }
public CharacterModels()
......
......@@ -43,7 +43,14 @@
@Html.DisplayFor(modelItem => item.Characteristics)
</td>
<td>
@Html.DisplayFor(modelItem => item.RelationShips)
@foreach (var rel in item.RelationShips) {
<td>
@Html.DisplayFor(modelItem => rel.Value))
</td>
<td>
@Html.DisplayFor(modelItem => rel.Key.FirstName + rel.Key.LastName))
</td>
}
</td>
<td>
@Html.ActionLink("Edit", "Edit", new { /* id=item.PrimaryKey */ }) |
......
@model IEnumerable<MVC.Models.HouseModels>
@{
ViewBag.Title = "Index";
ViewBag.Title = "House list";
}
<h2>Index</h2>
<h2>@ViewBag.Title</h2>
<p>
@Html.ActionLink("Create New", "Create")
......
......@@ -18,16 +18,15 @@
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
@Html.ActionLink("Nom d'application", "Index", "Home", new { area = "" }, new { @class = "navbar-brand" })
@Html.ActionLink("Thrones Tournament", "Index", "Home", new { area = "" }, new { @class = "navbar-brand" })
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li>@Html.ActionLink("Accueil", "Index", "Home")</li>
<li>@Html.ActionLink("Character", "Index", "Character")</li>
<li>@Html.ActionLink("House", "Index", "House")</li>
<li>@Html.ActionLink("Fight", "Index", "Fight")</li>
<li>@Html.ActionLink("À propos de", "About", "Home")</li>
<li>@Html.ActionLink("Contact", "Contact", "Home")</li>
<li>@Html.ActionLink("War", "Index", "War")</li>
<li>@Html.ActionLink("Territory", "Index", "Territory")</li>
</ul>
@Html.Partial("_LoginPartial")
</div>
......
......@@ -26,7 +26,7 @@ namespace WebApiGOT.Controllers
public void PostAddCharacter(CharacterDTO c)
{
Character cha = new Character(c.FirstName, c.LastName,c.Characteristics.PV,c.Characteristics.Type,c.Characteristics.Bravoury,c.Characteristics.Crazyness,c.House);
Character cha = new Character(c.FirstName, c.LastName,c.Characteristics.PV,c.Characteristics.Type,c.Characteristics.Bravoury,c.Characteristics.Crazyness,new House(c.House.Name, c.House.NbUnits));
BusinessLayer.ThronesTournamentManager busi = new BusinessLayer.ThronesTournamentManager();
busi.addCharacter(cha);
}
......
......@@ -6,20 +6,36 @@ using System.Web;
namespace WebApiGOT.Models
{
public class CharacteristicsDTO
{
public uint PV { get; set; }
public CharacterType Type { get; set; }
public int Bravoury { get; set; }
public int Crazyness { get; set; }
public CharacteristicsDTO(Characteristics c)
{
PV = c.PV;
Type = c.Type;
Bravoury = Bravoury;
Crazyness = Crazyness;
}
}
public class CharacterDTO
{
public string FirstName { get; set; }
public string LastName { get; set; }
public House House { get; set; }
public Characteristics Characteristics { get; set; }
public HouseDTO House { get; set; }
public CharacteristicsDTO Characteristics { get; set; }
public Dictionary<CharacterDTO, RelationshipType> RelationShips { get; set; }
public CharacterDTO(Character c)
{
FirstName = c.FirstName;
LastName = c.LastName;
House = c.House;
Characteristics = c.Characteristics;
House = new HouseDTO(c.House);
Characteristics = new CharacteristicsDTO(c.Characteristics);
RelationShips = new Dictionary<CharacterDTO, RelationshipType>();
foreach(var r in c.RelationShips)
{
......
......@@ -9,18 +9,18 @@ namespace WebApiGOT.Models
public class FightDTO
{
public String Name { get; set; }
public House Challenger1 { get; set; }
public House Challenger2 { get; set; }
public House Winner { get; set; }
public War War { get; set; }
public HouseDTO Challenger1 { get; set; }
public HouseDTO Challenger2 { get; set; }
public HouseDTO Winner { get; set; }
public WarDTO War { get; set; }
public FightDTO(Fight f)
{
Name = f.Name;
Challenger1 = f.Challenger1;
Challenger2 = f.Challenger2;
Winner = f.Winner;
War = f.War;
Challenger1 = new HouseDTO(f.Challenger1);
Challenger2 = new HouseDTO(f.Challenger2);
Winner = (f.Winner == null) ? null : new HouseDTO(f.Winner);
War = new WarDTO(f.War);
}
}
}
\ No newline at end of file
......@@ -10,6 +10,7 @@ namespace WebApiGOT.Models
{
public string Name { get; set; }
public int NbUnits { get; set; }
public HouseDTO(House h)
{
Name = h.Name;
......
......@@ -146,12 +146,15 @@
<Compile Include="App_Start\RouteConfig.cs" />
<Compile Include="App_Start\WebApiConfig.cs" />
<Compile Include="Controllers\CharacterController.cs" />
<Compile Include="Controllers\TerritoryController.cs" />
<Compile Include="Controllers\WarController.cs" />
<Compile Include="Controllers\FightController.cs" />
<Compile Include="Controllers\HouseController.cs" />
<Compile Include="Global.asax.cs">
<DependentUpon>Global.asax</DependentUpon>
</Compile>
<Compile Include="Models\CharacterDTO.cs" />
<Compile Include="Models\TerritoryDTO.cs" />
<Compile Include="Models\FightDTO.cs" />
<Compile Include="Models\HouseDTO.cs" />
<Compile Include="Models\WarDTO.cs" />
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment