public async Task <PaginatedList <ProductEntity> > Handle(GetProductsBySpecificationQuery request, CancellationToken cancellationToken)
        {
            InitOperation(request);
            if (CategoryNameQueried())
            {
                await CheckIfCategoryExist();
            }
            NormalizePagination();
            await LoadProducts();
            await LoadProductsTotalCount();

            return(PrepareResult());
        }
 private void InitOperation(GetProductsBySpecificationQuery request)
 {
     _specification = new ProductsQuerySpecification
     {
         CategoryNameQueried = request.CategoryNameQueried,
         CategoryName        = request.CategoryName,
         SearchPhraseQueried = request.SearchPhraseQueried,
         SearchPhrase        = request.SearchPhrase,
         PageIndexQueried    = request.PageIndexQueried,
         PageIndex           = request.PageIndex,
         PageSizeQueried     = request.PageSizeQueried,
         PageSize            = request.PageSize,
         SortOption          = GetSortOptionFrom(request),
     };
 }
 private SortOption GetSortOptionFrom(GetProductsBySpecificationQuery request)
 {
     return(request.OrderByQueried
         ? _sortOptionNameParser.GetSortOptionFor(request.OrderBy)
         : SortOption.Default);
 }