Пример #1
0
        public async Task CreateAsync(ProductTypeInputModel input)
        {
            var productType = new ProductType()
            {
                Name = input.Name,
            };

            await this.productTypeRepository.AddAsync(productType);

            await this.productTypeRepository.SaveChangesAsync();
        }
        public async Task <IActionResult> Create(ProductTypeInputModel input)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.View(input));
            }

            try
            {
                await this.productTypesService.CreateAsync(input);
            }
            catch (Exception ex)
            {
                this.ModelState.AddModelError(string.Empty, ex.Message);
                return(this.View(input));
            }

            return(this.RedirectToAction("Index", "Home"));
        }