public async Task <IActionResult> Edit(CategoryEditInputModel editInputModel) { if (!this.ModelState.IsValid) { this.ViewData["mainCategories"] = this.mainCategoryService .GetAllMainCategories() .To <CreateCategoryMainCategoryViewModel>(); return(this.View(editInputModel)); } await this.categoryService.EditCategoryAsync(editInputModel.To <CategoryServiceModel>()); return(this.RedirectToAction("All", "Categories")); }
public async Task <IActionResult> Edit(CategoryEditInputModel categoryEditInputModel) { if (!this.ModelState.IsValid) { return(this.View(categoryEditInputModel)); } var categoryServiceModel = categoryEditInputModel.To <CategoryServiceModel>(); if (!await this.categoryService.EditAsync(categoryServiceModel)) { this.TempData["Error"] = EditErrorMessage; return(this.View()); } return(this.Redirect($"/Categories/Recipes/{categoryServiceModel.Id}")); }