Commit 6e19fef6 authored by NEBOIT Jean-Charles's avatar NEBOIT Jean-Charles
Browse files

Update

parent 758f140f
......@@ -19,42 +19,44 @@ namespace BusinessLayer
DalManager = DalManager.Instance;
}
public List<String> HousesList()
public List<House> HousesList()
{
List<House> list = DalManager.HousesList();
return list.Select(House => House.Name).ToList();
/*List<House> list = DalManager.HousesList();
return list.Select(House => House.Name + " has " + House.NbUnits + " Units.").ToList();*/
return DalManager.HousesList();
}
public List<String> HousesList(int sup)
public List<House> HousesList(int sup)
{
List<House> list = DalManager.HousesList(sup);
return list.Select(House => House.Name).ToList();
/*List<House> list = DalManager.HousesList(sup);
return list.Select(House => House.Name).ToList();*/
return DalManager.HousesList(sup);
}
public List<String> CharactersCharacteristicsList()
public List<Characteristics> CharactersCharacteristicsList()
{
List<Characteristics> list = DalManager.CharactersCharacteristicsList();
return list.Select(c => "PV -> " + c.PV + ", Type -> " + c.Type + ", Bravoury -> " + c.Bravoury + ", Crazyness -> " + c.Crazyness).ToList();
/*List<Characteristics> list = DalManager.CharactersCharacteristicsList();
return list.Select(c => "PV -> " + c.PV + ", Type -> " + c.Type + ", Bravoury -> " + c.Bravoury + ", Crazyness -> " + c.Crazyness).ToList();*/
return DalManager.CharactersCharacteristicsList();
}
public List<String> CharactersList()
public List<Character> CharactersList()
{
List<Character> list = DalManager.CharactersList();
return list.Select(c => c.FirstName + " " + c.LastName).ToList();
/*List<Character> list = DalManager.CharactersList();
return list.Select(c => c.FirstName + " " + c.LastName).ToList();*/
return DalManager.CharactersList();
}
public List<String> CharactersList(int BravourySup, int PVSup)
public List<Character> CharactersList(int BravourySup, int PVSup)
{
List<Character> list = DalManager.CharactersList();
return list.Where(c => c.Characteristics.Bravoury > BravourySup && c.Characteristics.PV > PVSup).Select(c => c.FirstName + " " + c.LastName).ToList();
/*List<Character> list = DalManager.CharactersList();
return list.Where(c => c.Characteristics.Bravoury > BravourySup && c.Characteristics.PV > PVSup).Select(c => c.FirstName + " " + c.LastName).ToList();*/
return DalManager.CharactersList().Where(c => c.Characteristics.Bravoury > BravourySup && c.Characteristics.PV > PVSup).ToList();
}
public List<String> TerritoryList()
public List<Territory> TerritoryList()
{
List<Territory> list = DalManager.TerritoriesList();
return list.Select(t => t.Type + " owned by " + t.Owner.Name).ToList();
/*List<Territory> list = DalManager.TerritoriesList();
return list.Select(t => t.Type + " owned by " + t.Owner.Name).ToList();*/
return DalManager.TerritoriesList();
}
}
}
......@@ -34,6 +34,29 @@ namespace DataAccessLayer
return results;
}
private int UpdateByCommandBuilder(string request, DataTable table)
{
int result = 0;
using (SqlConnection sqlConnection = new SqlConnection(_connectionString))
{
SqlCommand sqlCommand = new SqlCommand(request, sqlConnection);
SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(sqlCommand);
SqlCommandBuilder sqlCommandBuilder = new SqlCommandBuilder(sqlDataAdapter);
sqlDataAdapter.UpdateCommand = sqlCommandBuilder.GetUpdateCommand();
sqlDataAdapter.InsertCommand = sqlCommandBuilder.GetInsertCommand();
sqlDataAdapter.DeleteCommand = sqlCommandBuilder.GetDeleteCommand();
sqlDataAdapter.MissingSchemaAction = MissingSchemaAction.AddWithKey;
result = sqlDataAdapter.Update(table);
}
return result;
}
public List<Character> CharactersList()
{
List<Character> res = new List<Character>();
......@@ -99,7 +122,7 @@ namespace DataAccessLayer
foreach (DataRow row in dataTable.Rows)
{
House house = new House(row[1].ToString());
House house = new House(Convert.ToInt32(row["Id"]) , row["name"].ToString(), Convert.ToInt32(row["nbUnits"]));
res.Add(house);
}
......@@ -128,12 +151,12 @@ namespace DataAccessLayer
public void addCharacter(Character character)
{
SelectByDataAdapter("INSERT INTO Character VALUES('" + character.FirstName + "','" + character.LastName + "'," + character.Characteristics.PV + "," + character.Characteristics.Type + "," + character.Characteristics.Bravoury + "," + character.Characteristics.Crazyness + "," + character.House.ID);
}
public void deleteCharacter(int id)
{
SelectByDataAdapter("DELETE FROM Character Where Id=" + id);
}
......
No preview for this file type
No preview for this file type
......@@ -56,10 +56,20 @@ namespace EntitiesLayer
RelationShips = new Dictionary<Character, RelationshipType>();
}
public Character(string firstName, string lastName, uint pv, CharacterType type, int bravoury, int crazyness, House house)
{
FirstName = firstName;
LastName = lastName;
Characteristics = new Characteristics(pv, type, bravoury, crazyness);
House = house;
RelationShips = new Dictionary<Character, RelationshipType>();
}
public Character(int id, string firstName, string lastName, uint pv, CharacterType type, int bravoury, int crazyness, House house, Dictionary<Character, RelationshipType> relationShips) : this(id, firstName, lastName, pv, type, bravoury, crazyness, house)
{
RelationShips = relationShips;
}
public void AddRelatives(Character c, RelationshipType rel)
{
......
......@@ -11,7 +11,7 @@ namespace ThronesTournamentConsole
{
BusinessLayer.ThronesTournamentManager businessLayer = new BusinessLayer.ThronesTournamentManager();
public void DisplayHouses()
/*public void DisplayHouses()
{
Console.WriteLine("---- Display Houses ----");
List<String> _listHouse = businessLayer.HousesList();
......@@ -51,18 +51,18 @@ namespace ThronesTournamentConsole
List<String> terr = businessLayer.TerritoryList();
for (int k = 0; k < terr.Count(); k++)
Console.WriteLine(terr[k]);
}
}*/
static void Main(string[] args)
{
Program game = new Program();
game.DisplayHouses();
/*game.DisplayHouses();
game.DisplayHouses(200);
game.DisplayCharacteristics();
game.DisplayTerritories();
game.DisplayCharacters();
game.DisplayCharacters(30, 50);
game.DisplayCharacters(30, 50);*/
Console.ReadKey();
}
}
......
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