public ActionResult DeleteConfirmed(int id)
        {
            Ingredient ingredient = IngredientRepo.Find(id);

            IngredientRepo.Remove(ingredient);
            return(RedirectToAction("Index"));
        }
예제 #2
0
        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 }));
        }
예제 #3
0
        public IActionResult Delete(string id)
        {
            var ingredient = _ingredientsRepository.Get(id);

            if (ingredient == null)
            {
                return(NotFound());
            }

            _ingredientsRepository.Remove(ingredient.id);

            return(NoContent());
        }
예제 #4
0
 public void Remove(int id)
 {
     _repo.Remove(id);
 }