public IActionResult GetById(int id)
 {
     try
     {
         return(Ok(_subCategoryService.GetSubCategory(id)));
     }
     catch (Exception)
     {
         return(BadRequest("Subcategory not found"));
     }
 }
Exemple #2
0
        public ActionResult GetSubCategory(string Id)
        {
            SubCategoryViewModel model;

            if (!string.IsNullOrEmpty(Id))
            {
                var res = _subCategoryService.GetSubCategory(Convert.ToDecimal(Id));
                model = AutoMapper.Mapper.Map <SubCategoryMaster, SubCategoryViewModel>(res);
            }
            else
            {
                model = new SubCategoryViewModel();
            }
            ViewBag.CategoryList = _categoryMasterService.GetCategoryList();
            return(PartialView("AddEditSubCategory", model));
        }
Exemple #3
0
        public ActionResult <SubCategoryDto> GetASubCategory(int id)
        {
            var subCategory = _subCategoryService.GetSubCategory(id);

            if (subCategory == null)
            {
                List <string> errorMessage = new List <string>();
                errorMessage.Add("Đã phát sinh lỗi, vui lòng thử lại");
                return(BadRequest(new ResponseDto(errorMessage, 500, subCategory)));
            }
            List <string> successMessage = new List <string>();

            successMessage.Add("Lấy thông tin thành công");
            var responseDto = new ResponseDto(successMessage, 200, subCategory);

            return(Ok(responseDto));
        }
Exemple #4
0
 public IActionResult GetByGenderId(int id)
 {
     return(Ok(_subCategoryService.GetSubCategory(id)));
 }
Exemple #5
0
        public async Task <JsonResult> GetSubCategory([FromBody] CategoryDto Category)
        {
            var subCategory = await _subCategoryService.GetSubCategory(Category.Id);

            return(Json(subCategory));
        }
 public SubCategoryDto GetSubCategory([FromQuery] Guid id)
 {
     return(service.GetSubCategory(id));
 }