public async Task <IActionResult> Create() { SubCategoryAddDto subCategoryAddDto = new SubCategoryAddDto(); subCategoryAddDto.CategoryList = new SelectList(await _categoryService.GetListAsync(), "Id", "Name"); return(View(subCategoryAddDto)); }
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)); }