Exemplo n.º 1
0
        public async Task <IActionResult> Create()
        {
            SubCategoryAddDto subCategoryAddDto = new SubCategoryAddDto();

            subCategoryAddDto.CategoryList = new SelectList(await _categoryService.GetListAsync(), "Id", "Name");
            return(View(subCategoryAddDto));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Create(SubCategoryAddDto subCategoryAddDto)
        {
            if (ModelState.IsValid)
            {
                await _subCategoryService.InsertAsync(new SubCategory
                {
                    Name       = subCategoryAddDto.Name,
                    CategoryId = subCategoryAddDto.CategoryId
                });

                return(RedirectToAction("Index", "SubCategory"));
            }
            subCategoryAddDto.CategoryList = new SelectList(await _categoryService.GetListAsync(), "Id", "Name");
            return(View(subCategoryAddDto));
        }