Exemplo n.º 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();
            }
        }
Exemplo n.º 2
0
 public int Update(Player item)
 {
     using (var context = new FSISContext())
     {
         context.Entry(item).State = System.Data.Entity.EntityState.Modified;
         return(context.SaveChanges());
     }
 }
Exemplo n.º 3
0
 public int Player_Delete(int playerid)
 {
     using (var context = new FSISContext())
     {
         var existing = context.Players.Find(playerid);
         context.Players.Remove(existing);
         return(context.SaveChanges());
     }
 }
Exemplo n.º 4
0
 public int Add(Player item)
 {
     using (var context = new FSISContext())
     {
         context.Players.Add(item);
         context.SaveChanges();
         return(item.PlayerID);
     }
 }
Exemplo n.º 5
0
 public int Player_Add(Player player)
 {
     using (var context = new FSISContext())
     {
         context.Players.Add(player);
         context.SaveChanges();
         return(player.PlayerID);
     }
 }
Exemplo n.º 6
0
 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();
     }
 }
Exemplo n.º 7
0
 public int Player_Add(Player info)
 {
     using (var context = new FSISContext())
     {
         Player addedItem = context.Players.Add(info);
         context.SaveChanges();
         return(addedItem.PlayerID);
     }
 }
Exemplo n.º 8
0
        public int Team_Delete(int teamid)
        {
            using (var context = new FSISContext())
            {
                var existing = context.Teams.Find(teamid);

                context.Teams.Remove(existing);

                return(context.SaveChanges());
            }
        }
Exemplo n.º 9
0
        public int Team_Add(Team item)
        {
            using (var context = new FSISContext())
            {
                context.Teams.Add(item);

                context.SaveChanges();

                return(item.TeamID);
            }
        }
Exemplo n.º 10
0
 /*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());
     }
 }
Exemplo n.º 11
0
        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());
            }
        }