public ActionResult Index() { CategoryListPageViewModel model = new CategoryListPageViewModel(); FindAllCategoriesResponse response = categoryService.FindAllCategories(); if (response.Success) { model.CategoryViewModels = response.Categories.ConvertToCategoryViewModelList(); model.Success = true; } else { model.Success = false; model.ErrorMessage = response.Message; } return(View(model)); }
public ActionResult Delete(int categoryId) { DeleteCategoryRequest request = new DeleteCategoryRequest(); DeleteCategoryResponse response = new DeleteCategoryResponse(); request.CategoryId = categoryId; response = categoryService.DeleteCategory(request); if (response.Success) { return(RedirectToAction("Index")); } else { CategoryListPageViewModel model = new CategoryListPageViewModel(); model.Success = false; model.ErrorMessage = response.Message; return(View("Index", model)); } }