public async Task <IActionResult> PutProducts(int id, Products products) { if (id != products.ProductId) { return(BadRequest()); } _context.Entry(products).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProductsExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task UpdateTutorial(Tutorial tutorial) { _context.Entry(tutorial).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TutorialExists(tutorial.Id)) { throw new ApplicationException($"Tutorial with {tutorial.Id} does not exist"); } else { throw; } } }