public PagingQueryResponse <Store> GetStores(PagingQueryRequest query) { var specificaion = new RetrievableStoreSpecification().And(new StoreMatchingInOwnerSpecificaion(query.UserId)); var totalCount = ReadOnlyDataContext.Stores.Where(specificaion.IsSatisfied()).AsNoTracking().Count(); var result = new PagingQueryResponse <Store> { PageSize = query.PageSize, CurrentPage = query.PageIndex, TotalCount = totalCount, Result = DataContext.Stores .Where(specificaion.IsSatisfied()) .Include(c => c.Location) .Include(c => c.Pictures) .Include(c => c.Users) .OrderByDescending(c => c.CreationDate) .Skip((query.PageIndex - 1) * query.PageSize).Take(query.PageSize).ToList() }; return(result); }
public PagingQueryResponse <Store> GetDiscountedStores(PagingQueryRequest query) { //ToDo Scnerio should be completed var specificaion = new RetrievableStoreSpecification(); var totalCount = ReadOnlyDataContext.Stores.Where(specificaion.IsSatisfied()).AsNoTracking().Count(); var result = new PagingQueryResponse <Store> { PageSize = query.PageSize, CurrentPage = query.PageIndex, TotalCount = totalCount, Result = DataContext.Stores .Where(specificaion.IsSatisfied()) .Include(c => c.Location) .Include(c => c.Pictures) .OrderByDescending(c => c.CreationDate) .Skip((query.PageIndex - 1) * query.PageSize).Take(query.PageSize).ToList() }; return(result); }