Ejemplo n.º 1
0
        public async Task <PageDataContainer <AnnoucementDto> > GetPagedAnnoucements(AnnoucementFilterArguments filterOptions,
                                                                                     PageArguments paginateParams, SortingArguments orderParams)
        {
            _dataSet = _context.Annoucements;
            IQueryable <Annoucement>        annoucements         = IncludeProperties(_dataSet);
            IQueryable <Annoucement>        filteredAnnoucements = ApplySeachQuery(annoucements, filterOptions);
            IOrderedQueryable <Annoucement> orderedAnnoucements  = OrderAnnoucements(filteredAnnoucements, orderParams);
            var pagedAnnoucements = await orderedAnnoucements.GetPageAsync(paginateParams);

            return(_mapper.Map <PageDataContainer <AnnoucementDto> >(pagedAnnoucements));
        }
        public async Task <PageDataContainer <BrandDto> > GetPagedBrands(BrandFilterArguments filterOptions, SortingArguments sortingArguments, PageArguments pageArguments)
        {
            var filters = new List <Expression <Func <Brand, bool> > >()
            {
                brand => brand.Title.Contains(filterOptions.Title ?? ""),
            };

            var includes = new string[] { "BrandCategories.Category" };

            var orderParameters = new List <OrderParams <Brand> >()
            {
                new OrderParams <Brand> {
                    OrderBy    = (x) => x.Title,
                    Descending = (sortingArguments.Direction == "desc")
                }
            };

            IOrderedQueryable <Brand> query       = GetAllForPaging(includes, filters, orderParameters);
            PageDataContainer <Brand> pagedBrands = await query.GetPageAsync(pageArguments);

            return(_mapper.Map <PageDataContainer <BrandDto> >(pagedBrands));
        }
Ejemplo n.º 3
0
 public static Task <Pagination <TResult> > GetPageAsync <TSource, TResult>(this IOrderedQueryable <TSource> query, int pageNumber, int pageSize, Expression <Func <TSource, TResult> > serverProjection)
 {
     return(query.GetPageAsync(pageNumber, pageSize, serverProjection, x => x));
 }
Ejemplo n.º 4
0
 public static Task <Pagination <T> > GetPageAsync <T>(this IOrderedQueryable <T> query, int pageNumber, int pageSize)
 {
     return(query.GetPageAsync(pageNumber, pageSize, x => x, x => x));
 }