Exemple #1
0
        public IActionResult GetSubCategories()
        {
            QueryableBaseResponse <SubCategory> result = null;

            try
            {
                result = _subService.GetSubCategories();
                if (result.code == ResponseCode.SUCCESS)
                {
                    return(Ok(result.queryableResponse));
                }
                else
                {
                    return(BadRequest());
                }
            }
            catch (Exception)
            {
                return(BadRequest());
            }
        }
Exemple #2
0
        public ActionResult GetSubCategoriesInJson()
        {
            if (!_workContext.CurrentCustomer.IsRegistered())
            {
                return(Unauthorized());
            }


            if (!_workContext.CurrentCustomer.IsInCustomerRole(RolesType.Administrators, true) && !_workContext.CurrentCustomer.IsInCustomerRole(RolesType.ConsultationAdmin, true))
            {
                return(Forbid());
            }

            //Server Side Parameters
            int start = Convert.ToInt32(Request.Form["start"].FirstOrDefault());

            int    length         = Convert.ToInt32(Request.Form["length"]);
            string searchValue    = Request.Form["search[value]"];
            string sortColumnName = Request.Form["columns[" + Request.Form["order[0][column]"] + "][name]"];
            string sortDirection  = Request.Form["order[0][dir]"];



            var subCategoryInDb = _subCategory.GetSubCategories(start, length, searchValue, sortColumnName, sortDirection);

            var subCategory = new SubCategoryOutputModel
            {
                SubCategories = subCategoryInDb.Select(m => new SubCategoryModel
                {
                    Id           = m.Id,
                    Name         = m.Name,
                    Description  = m.Description,
                    CategoryId   = m.CategoryId,
                    CategoryName = m.Category?.Name,
                    IsActive     = m.IsActive
                }).ToList()
            };

            return(Json(new { data = subCategory.SubCategories }));
        }
 public IEnumerable <SubCategoryDto> ListSubCategories(Guid categoryId)
 {
     return(service.GetSubCategories(categoryId));
 }
 public IActionResult GetSubCategories()
 {
     return(Ok(_subCategoryService.GetSubCategories()));
 }