}//eom public void RecordGame(Game item) { if (item.HomeTeamID == item.VisitingTeamID) { throw new Exception("Home and Visiting teams cannot be be the same."); } using (var context = new FSISContext()) { context.Games.Add(item); Team hometeam = (from x in context.Teams where x.TeamID == item.HomeTeamID select x).FirstOrDefault(); Team visitingteam = (from x in context.Teams where x.TeamID == item.VisitingTeamID select x).FirstOrDefault(); if (item.HomeTeamScore > item.VisitingTeamScore) { hometeam.Wins += 1; visitingteam.Losses += 1; context.Entry(hometeam).Property(y => y.Wins).IsModified = true; context.Entry(visitingteam).Property(y => y.Losses).IsModified = true; } else { hometeam.Losses += 1; visitingteam.Wins += 1; context.Entry(hometeam).Property(y => y.Losses).IsModified = true; context.Entry(visitingteam).Property(y => y.Wins).IsModified = true; } context.SaveChanges(); } }
public int Update(Player item) { using (var context = new FSISContext()) { context.Entry(item).State = System.Data.Entity.EntityState.Modified; return(context.SaveChanges()); } }
public int Player_Delete(int playerid) { using (var context = new FSISContext()) { var existing = context.Players.Find(playerid); context.Players.Remove(existing); return(context.SaveChanges()); } }
public int Add(Player item) { using (var context = new FSISContext()) { context.Players.Add(item); context.SaveChanges(); return(item.PlayerID); } }
public int Player_Add(Player player) { using (var context = new FSISContext()) { context.Players.Add(player); context.SaveChanges(); return(player.PlayerID); } }
public void Player_Update(Player info) { using (var context = new FSISContext()) { DbEntityEntry <Player> existing = context.Entry(info); existing.State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); } }
public int Player_Add(Player info) { using (var context = new FSISContext()) { Player addedItem = context.Players.Add(info); context.SaveChanges(); return(addedItem.PlayerID); } }
public int Team_Delete(int teamid) { using (var context = new FSISContext()) { var existing = context.Teams.Find(teamid); context.Teams.Remove(existing); return(context.SaveChanges()); } }
public int Team_Add(Team item) { using (var context = new FSISContext()) { context.Teams.Add(item); context.SaveChanges(); return(item.TeamID); } }
/*public int Discontinue(int productid) * { * using (var context = new FSISContext()) * { * var existing = context.Players.Find(productid); * existing.Discontinued = true; * context.Entry(existing).State = System.Data.Entity.EntityState.Modified; * return context.SaveChanges(); * } * }*/ public int Delete(int productid) { using (var context = new FSISContext()) { var existing = context.Players.Find(productid); if (existing == null) { throw new Exception("Record has been removed from database"); } context.Players.Remove(existing); return(context.SaveChanges()); } }
public int Delete(int playerid) { using (var context = new FSISContext()) { var existingPlayer = context.Players.Find(playerid); if (existingPlayer == null) { throw new Exception("Player has been removed from the database"); } context.Players.Remove(existingPlayer); return(context.SaveChanges()); } }