public async Task <IActionResult> PutCategory(int id, Category category) { if (id != category.Id) { return(BadRequest()); } _context.Entry(category).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CategoryExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutRecipe([FromRoute] int id, [FromBody] Recipe recipe) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != recipe.Id) { return(BadRequest()); } _context.Entry(recipe).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RecipeExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }