public async Task <IActionResult> PutVideoGame(int id, VideoGame videoGame) { if (id != videoGame.GameId) { return(BadRequest()); } _context.Entry(videoGame).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!VideoGameExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult <Product> > Post(Product product) { using (var context = new DotNetContext()) { context.Product.Add(product); await context.SaveChangesAsync(); return(CreatedAtAction(nameof(Get), new { id = product.Id }, product)); // Get all the products from the database. } }