public IActionResult Create(ProductCategoryCreateViewModel model)
 {
     if (ModelState.IsValid)
     {
         ProductCategory productCategory = new ProductCategory
         {
             ProductCategoryName = model.Name
         };
         _context.Set <ProductCategory>().Add(productCategory);
         return(RedirectToAction("Index"));
     }
     return(View(model));
 }
Ejemplo n.º 2
0
        public async Task <IActionResult> Create(ProductCategoryCreateViewModel input)
        {
            if (ModelState.IsValid)
            {
                var category = await this.manager.CreateProductCategory(input);

                TempData["success"] = "Категорията е създанена!";
            }
            else
            {
                var errors = ModelState.GetErrorsList();
                TempData["errors"] = errors;
            }

            return(RedirectToAction(nameof(this.Index)));
        }