public ActionResult DeleteConfirmed(int id) { Ingredient ingredient = IngredientRepo.Find(id); IngredientRepo.Remove(ingredient); return(RedirectToAction("Index")); }
public ActionResult Delete(DeleteIngredientViewModel viewModel) { if (viewModel == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var ingredient = _ingredientsRepository.GetById((int)viewModel.Id); if (ingredient == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } _ingredientsRepository.Remove(ingredient); if (!_ingredientsRepository.Save()) { this.AddNotification("Грешка при опти за изтриване на съставката.", NotificationType.ERROR); return(RedirectToAction("Index", new { page = viewModel.CurrentPage, searchText = viewModel.SearchText })); } this.AddNotification("Съставката е изтрита.", NotificationType.SUCCESS); return(RedirectToAction("Index", new { page = viewModel.CurrentPage, searchText = viewModel.SearchText })); }
public IActionResult Delete(string id) { var ingredient = _ingredientsRepository.Get(id); if (ingredient == null) { return(NotFound()); } _ingredientsRepository.Remove(ingredient.id); return(NoContent()); }
public void Remove(int id) { _repo.Remove(id); }