public WarDTO GetWarById(int p_id) { WarDTO War; string sql = "SELECT * FROM Wars WHERE WarId = @id"; using (SqlConnection sqlCon = new SqlConnection(_connectionString)) { sqlCon.Open(); using (SqlCommand sqlCmd = new SqlCommand(sql, sqlCon)) { sqlCmd.Parameters.Add("@id", SqlDbType.Int).Value = p_id; SqlDataReader rdr = sqlCmd.ExecuteReader(); if (rdr.Read()) { int id = rdr.GetInt32(0); War = new WarDTO(id); } else { War = new WarDTO(); } }; sqlCon.Close(); }; return(War); }
public IHttpActionResult GetWarById(int id) { WarDTO War = GameManager.Instance.GetWarById(id); if (War.Id == -1) { return(NotFound()); } else { return(Ok(War)); } }
// PUT: api/Wars/{id} public IHttpActionResult Put(int id, [FromBody] WarDTO value) { if (!ModelState.IsValid) { return(BadRequest("Invalid data")); } ThronesTournamentManager m = new ThronesTournamentManager(); m.UpdateWar(value.Transform()); return(Ok()); }
public WarModel(WarDTO warDTO) { Fights = new List <FightModel>(); ID = warDTO.ID; FirstHouse = new HouseModel(warDTO.FirstHouse); SecondHouse = new HouseModel(warDTO.SecondHouse); ID_WinnerHouse = warDTO.ID_WinnerHouse; foreach (FightDTO fight in warDTO.Fights) { Fights.Add(new FightModel(fight)); } }
public void AddWar(WarDTO War) { string sql = "INSERT INTO Wars"; using (SqlConnection sqlCon = new SqlConnection(_connectionString)) { sqlCon.Open(); using (SqlCommand sqlCmd = new SqlCommand(sql, sqlCon)) { sqlCmd.ExecuteNonQuery(); }; sqlCon.Close(); }; }
public WarDTO GetLastWar() { var war = businessManager.GetLastWar(); WarDTO warDTO = new WarDTO() { Fights = war.Fights.Select(fight => new FightDTO() { HouseChalleging = fight.HouseChalleging.Name, HouseChalleged = fight.HouseChalleged.Name, WinningHouse = fight.WinningHouse.Name, Territory = new TerritoryDTO() { Owner = fight.Territory.Owner.FirstName + " " + fight.Territory.Owner.LastName, TerritoryType = fight.Territory.TerritoryType.ToString() } }).ToList <FightDTO>() }; return(warDTO); }
public void AddWar(WarDTO War) { DalManager.Instance.AddWar(War); }
public IHttpActionResult PostWar([FromBody] WarDTO War) { GameManager.Instance.AddWar(War); return(Ok()); }
public void AddWar(WarDTO War) { bddInterf.AddWar(War); }
public WarDTO GetWarById(int id) { WarDTO war = new WarDTO(businessManager.GetWarById(id)); return(war); }