예제 #1
0
        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));
        }
예제 #2
0
        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));
            }
        }