Beispiel #1
0
        public FindAllCategoriesResponse FindAllCategories()
        {
            FindAllCategoriesResponse response = new FindAllCategoriesResponse();

            try
            {
                response.Categories = categoryRepository.ReadAll();
                response.Success    = true;
            }
            catch (Exception ex)
            {
                response.Success = false;
                response.Message = ex.Message;
            }
            return(response);
        }
Beispiel #2
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));
        }
Beispiel #3
0
        public ActionResult Edit(int categoryId)
        {
            CategorySinglePageViewModel model    = new CategorySinglePageViewModel();
            FindAllCategoriesResponse   response = categoryService.FindAllCategories();

            if (response.Success)
            {
                model.CategoryViewModel = response.Categories.
                                          Where(x => x.CategoryId == categoryId).
                                          FirstOrDefault().
                                          ConvertToCategoryViewModel();
                model.Success = true;
            }
            else
            {
                model.Success      = false;
                model.ErrorMessage = response.Message;
            }
            return(View(model));
        }