public async Task <IActionResult> DeleteIngredient(int id) { if (await _ingredientServices.IsIngredientUsedAsync(id)) { ModelState.AddModelError(string.Empty, "The ingredient is currently being used in a cokctail and thus cannot be deleted."); return(View("ManageIngredients")); } await _ingredientServices.DeleteAsync(id); return(View("ManageIngredients")); }
public async Task <IActionResult> Delete(int id) { try { await ingredientServices.DeleteAsync(id); return(Ok()); } catch (InvalidOperationException) { return(BadRequest()); } }