public async Task <IActionResult> ChooseCategory() { SupplementCategoryServiceModel model = new SupplementCategoryServiceModel { Categories = await this.GetCategoriesSelectListItems() }; return(View(model)); }
public async Task <IActionResult> ChooseCategory(SupplementCategoryServiceModel category) { if (!ModelState.IsValid) { category.Categories = await this.GetCategoriesSelectListItems(); return(View(nameof(ChooseCategory), category)); } bool isCategoryExistingById = await this.categoryService.IsCategoryExistingById(category.CategoryId, false); if (!isCategoryExistingById) { TempData.AddErrorMessage(string.Format(EntityNotFound, CategoryEntity)); return(RedirectToAction(nameof(Index))); } return(RedirectToAction(nameof(Create), new { category.CategoryId })); }