public async Task <IActionResult> Create(CreateProductCategoryViewModel vm)
        {
            if (ModelState.IsValid)
            {
                var newCategory = Mapper.Map(vm).ToANew <ProductCategory>();
                newCategory.Id = Guid.NewGuid();

                var lkpService = _lookupServiceFactory.Create <ProductCategory>();
                await lkpService.InsertAsync(newCategory);
            }

            return(RedirectToAction(nameof(CategoriesController.Categories)));
        }
示例#2
0
        public IActionResult CreateProductCategory(CreateProductCategoryViewModel model)
        {
            if (ModelState.IsValid)
            {
                ProductCategory productCategory = new ProductCategory()
                {
                    Name = model.ProductCategoryName
                };

                productCategoryRepository.Add(productCategory);
                productCategoryRepository.Save();

                return(RedirectToAction("ListProductCategories"));
            }

            return(View(model));
        }