public async Task <IActionResult> PutIngredientSubstitute(int id, IngredientSubstitute ingredientSubstitute) { if (id != ingredientSubstitute.IngredientId) { return(BadRequest()); } _context.Entry(ingredientSubstitute).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!IngredientSubstituteExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult <IngredientSubstitute> > PostIngredientSubstitute(IngredientSubstitute ingredientSubstitute) { _context.IngredientSubstitute.Add(ingredientSubstitute); try { await _context.SaveChangesAsync(); } catch (DbUpdateException) { if (IngredientSubstituteExists(ingredientSubstitute.IngredientId)) { return(Conflict()); } else { throw; } } return(CreatedAtAction("GetIngredientSubstitute", new { id = ingredientSubstitute.IngredientId }, ingredientSubstitute)); }