Ejemplo n.º 1
0
        public async Task <IEnumerable <CategoryViewModel> > GetCategoriesAsync(CategorySearchParams searchParams)
        {
            var specification = new CategoryFilterSpecification(searchParams);

            return(await _categoryRepository.ListAsync <CategoryViewModel>(specification,
                                                                           CategoryHelpers.GetCategoryMapperConfiguration()));
        }
Ejemplo n.º 2
0
        public CategoryFilterSpecification(CategorySearchParams searchParams)
            : base(x => string.IsNullOrEmpty(searchParams.CategoryName) || x.Name.Contains(searchParams.CategoryName))
        {
            if (searchParams.OrderByDir.ToUpper() == "DESC")
            {
                ApplyFieldOrderByDescending(searchParams.SortBy);
            }
            else
            {
                ApplyFieldOrderBy(searchParams.SortBy);
            }

            ApplyPaging(searchParams.Offset, searchParams.Limit);
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> GetMany([FromQuery] CategorySearchParams searchParams)
        {
            if (!BaseHelpers.IsPaginatonSearchParamsValid(searchParams, out ErrorResponse errorResponse))
            {
                return(new BadRequestObjectResult(errorResponse));
            }

            FilteredDataViewModel <CategoryViewModel>
            result = await _mediator.Send(new GetCategoriesQuery(searchParams));

            return(Ok(new FilteredResponse <CategoryViewModel>(searchParams)
            {
                Data = result.Data,
                Count = result.Count,
            }));
        }
Ejemplo n.º 4
0
 public GetCategoriesQuery(CategorySearchParams searchParams)
 {
     SearchParams = searchParams;
 }
Ejemplo n.º 5
0
        public async Task <int> GetCategoriesCountAsync(CategorySearchParams searchParams)
        {
            var specification = new CategoryFilterSpecification(searchParams);

            return(await _categoryRepository.GetTotalCountAsync(specification));
        }