Exemplo n.º 1
0
 public ActionResult CreateCategory(CreateCategoryViewModel category)
 {
     if (!ModelState.IsValid)
     {
         return(View());
     }
     if (MenuService.CreteCategory(category.ToEntity()))
     {
         return(RedirectToAction("Index", "menu"));
     }
     return(View());
 }
Exemplo n.º 2
0
        public IActionResult Create(CreateCategoryViewModel model)
        {
            if (ModelState.IsValid)
            {
                //TODO: set message
                var category   = model.ToEntity();
                var categories = new List <Category>
                {
                    category
                };
                _unitOfWork.BookMetas.AddCategories(categories);
                _unitOfWork.SaveChanges();
                return(RedirectToAction("Index"));
            }

            //TODO: set message
            return(View(model));
        }