Esempio n. 1
0
        public IActionResult Edit(int id)
        {
            Result <CategoryViewModel> result;
            CategoryViewModel          categoryViewModel = new CategoryViewModel();
            Result <CategoryDO>        categoryResult    = _categoryBL.GetById(id);

            if (categoryResult.IsSuccess)
            {
                Result <List <CategoryDO> > categoryList = _categoryBL.GetAll();
                if (categoryList.IsSuccess)
                {
                    categoryViewModel.CategoryDO   = categoryResult.Data;
                    categoryViewModel.CategoryList = categoryList.Data;
                    result = new Result <CategoryViewModel>(categoryViewModel);
                }
                else
                {
                    result = new Result <CategoryViewModel>(categoryList.IsSuccess, categoryList.ResultType, "An error occured" + " " + categoryList.Message);
                }
            }
            else
            {
                result = new Result <CategoryViewModel>(categoryResult.IsSuccess, categoryResult.ResultType, "An error occured" + " " + categoryResult.Message);
            }

            return(View(result));
        }
        public async Task <IActionResult> GetById([FromRoute] string id)
        {
            var category = await _categoryBL.GetById(id);

            return(Ok(category));
        }
Esempio n. 3
0
        public IActionResult GetCategoryById(int categoryId)
        {
            Result <CategoryDO> result = _categoryBL.GetById(categoryId);

            return(Json(result));
        }