示例#1
0
        }//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();
            }
        }
示例#2
0
 public int Update(Player item)
 {
     using (var context = new FSISContext())
     {
         context.Entry(item).State = System.Data.Entity.EntityState.Modified;
         return(context.SaveChanges());
     }
 }
 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();
     }
 }