public ActionResult Edit(Guid id)
        {
            var foodClass     = _foodClassService.GetById(id);
            var foodClassForm = FoodClassForm.FromFoodClass(foodClass);

            return(View(foodClassForm));
        }
        public ActionResult Edit(Guid id, FoodClassForm foodClassForm)
        {
            if (!ModelState.IsValid)
            {
                return(View(foodClassForm));
            }
            var available = _foodClassService.IsNameAvailable(foodClassForm.Name, id);

            if (!available)
            {
                return(View(foodClassForm).WithError("Ya existe una clase de comida con el nombre ingresado."));
            }

            _foodClassService.Edit(foodClassForm.ToFoodClass());

            return(RedirectToAction("Index", new FoodClassListFiltersModel().GetRouteValues()).WithSuccess("Clase de comida editada"));
        }
        public ActionResult Create(FoodClassForm foodClassForm)
        {
            if (!ModelState.IsValid)
            {
                return View(foodClassForm);
            }
            var available = _foodClassService.IsNameAvailable(foodClassForm.Name, Guid.Empty);
            if (!available)
            {
                return View(foodClassForm).WithError("Ya existe una clase de comida con el nombre ingresado.");
            }

            var foodClass = foodClassForm.ToFoodClass();

            _foodClassService.Create(foodClass);

            return RedirectToAction("Index", new FoodClassListFiltersModel().GetRouteValues()).WithSuccess("Clase de comida creada");
        }
 public ActionResult Create()
 {
     var foodClassForm = new FoodClassForm();
     return View(foodClassForm);
 }
        public ActionResult Create()
        {
            var foodClassForm = new FoodClassForm();

            return(View(foodClassForm));
        }