public async Task <IActionResult> Create(CategoryCreateInputModel createInputModel) { if (!this.ModelState.IsValid) { this.ViewData["mainCategories"] = this.mainCategoryService .GetAllMainCategories() .To <CreateCategoryMainCategoryViewModel>(); return(this.View()); } await this.categoryService.CreateCategoryAsync(createInputModel.To <CategoryServiceModel>()); return(this.Redirect("All")); }
public async Task <IActionResult> Create(CategoryCreateInputModel categoryCreateInputModel) { if (!this.ModelState.IsValid) { return(this.View(categoryCreateInputModel)); } var categoryServiceModel = categoryCreateInputModel.To <CategoryServiceModel>(); if (!await this.categoryService.CreateAsync(categoryServiceModel)) { this.TempData["Error"] = CreateErrorMessage; return(this.View()); } var categoryId = await this.categoryService.GetIdByTitleAsync(categoryServiceModel.Title); return(this.Redirect($"/Categories/Recipes/{categoryId}")); }