Beispiel #1
0
 public void DeleteGame(Game game)
 {
     using (var ctx = new ABStoreContext())
     {
         ctx.Games.Remove(game);
         ctx.SaveChanges();
     }
 }
Beispiel #2
0
 public void CreateGame(Game game)
 {
     using (var ctx = new ABStoreContext())
     {
         ctx.Games.Add(game);
         ctx.SaveChanges();
     }
 }
Beispiel #3
0
 public void RegisterUser(User user)
 {
     using (var ctx = new ABStoreContext())
     {
         ctx.Users.Add(user);
         ctx.Entry(user).State = EntityState.Added;
         ctx.SaveChanges();
     }
 }
Beispiel #4
0
 public void UpdateGame(Game game)
 {
     using (var ctx = new ABStoreContext())
     {
         ctx.Games.Attach(game);
         ctx.Entry(game).State = EntityState.Modified;
         ctx.SaveChanges();
     }
 }
Beispiel #5
0
        public void DeleteUser(int userId)
        {
            using (var ctx = new ABStoreContext())
            {
                User usr = ctx.Users.Include(x => x.UserLibrary).First(x => x.Id == userId);

                ctx.Users.Remove(usr);
                ctx.SaveChanges();
            }
        }
Beispiel #6
0
        public void UpdateUser(User user)
        {
            using (var ctx = new ABStoreContext())
            {
                ctx.Users.Attach(user);
                ctx.Entry(user).State = EntityState.Modified;

                foreach (var libItem in user.UserLibrary)
                {
                    if (libItem.Id == 0)
                    {
                        ctx.Entry(libItem).State = EntityState.Added;
                    }
                }
                ctx.SaveChanges();
            }
        }