public static void EditPlayer(Player oldPlayer) { var ctx = new CybersportDBEntities(); oldPlayer.Country = ctx.Countries.ToList().First(c => c.CountryID == oldPlayer.CountryID); oldPlayer.Role = ctx.Roles.ToList().First(r => r.RoleID == oldPlayer.RoleID); ctx.Entry(oldPlayer).State = System.Data.Entity.EntityState.Modified; ctx.SaveChanges(); }
public static void EditTournament(Tournament oldChamp) { var ctx = new CybersportDBEntities(); oldChamp.City = ctx.Cities.ToList().First(c => c.CityID == oldChamp.CityID); Tournament changedChamp = ctx.Tournaments.Where(x => x.TournamentID == oldChamp.TournamentID).First(); changedChamp.Name = oldChamp.Name; changedChamp.Money = oldChamp.Money; changedChamp.CityID = oldChamp.CityID; changedChamp.City = oldChamp.City; changedChamp.Finish = oldChamp.Finish; changedChamp.Start = oldChamp.Start; changedChamp.MembersCount = oldChamp.MembersCount; ctx.Entry(changedChamp).State = System.Data.Entity.EntityState.Modified; ctx.SaveChanges(); }
public static void EditTeam(Team oldTeam) { var ctx = new CybersportDBEntities(); oldTeam.Region = ctx.Regions.ToList().First(r => r.RegionID == oldTeam.RegionID); Team changedTeam = ctx.Teams.Where(x => x.TeamID == oldTeam.TeamID).First(); changedTeam.Name = oldTeam.Name; changedTeam.Money = oldTeam.Money; changedTeam.Defeats = oldTeam.Defeats; changedTeam.Draws = oldTeam.Draws; changedTeam.Wins = oldTeam.Wins; changedTeam.RegionID = oldTeam.RegionID; changedTeam.Region = oldTeam.Region; changedTeam.Rating = oldTeam.Rating; ctx.Entry(changedTeam).State = System.Data.Entity.EntityState.Modified; ctx.SaveChanges(); }