Ejemplo n.º 1
0
        public async Task <IActionResult> UpdateUser([FromBody] User user)
        {
            using (var context = new GameLibraryDbContext())
            {
                context.Users.Update(user);
                await context.SaveChangesAsync();

                return(Ok());
            }
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> UpdateGame([FromBody] Game game)
        {
            using (var context = new GameLibraryDbContext())
            {
                context.Games.Update(game);
                await context.SaveChangesAsync();

                return(Ok());
            }
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> DeleteUser([FromQuery] int id)
        {
            using (var context = new GameLibraryDbContext())
            {
                var user = await context.Users.FirstOrDefaultAsync(x => x.Id == id);

                context.Users.Remove(user);
                await context.SaveChangesAsync();

                return(Ok());
            }
        }