Ejemplo n.º 1
0
        public ActionResult RenameIngredient(RenameIngredientModel model)
        {
            if (string.IsNullOrWhiteSpace(model.Name))
            {
                ViewBag.Error = "Name cannot be empty";
                return(RedirectToAction("Ingredient", new { id = model.Id }));
            }

            _ingredientRepository.Rename(model.Id, model.Name);

            return(RedirectToAction("Ingredients", "List"));
        }
Ejemplo n.º 2
0
        public ActionResult Ingredient(int id)
        {
            var ingredient = _ingredientRepository.Get(id);

            if (!ingredient.Any())
            {
                ViewBag.Error = "Ingredient not found!";
                return(RedirectToAction("Ingredients", "List"));
            }

            var model = new RenameIngredientModel
            {
                Id   = id,
                Name = ingredient.Single().Name
            };

            return(View(model));
        }