コード例 #1
0
 /// <summary>
 /// Get all deals.
 /// </summary>
 /// <param name="param"></param>
 /// <returns></returns>
 public async Task <PagedResult <DealDto> > GetAllDeals(BasePagingDto param)
 {
     return(await unitOfWork.GetRepository <Deal>()
            .SearchFor(e =>
                       (e.DealValidFrom <= DateTime.Now) && (DateTime.Now <= e.DealValidTo) &&
                       !(e.Brand.Disabled ?? false))
            .Include(e => e.Brand)
            .Include(e => e.Images)
            .OrderBy(e => e.Name)
            .Select(e => new DealDto()
     {
         Name = e.Name,
         DealType = (DealType)e.DealType,
         Gender = (GenderType)e.Gender,
         Currency = e.Currency,
         DealValidFrom = e.DealValidFrom,
         DealValidTo = e.DealValidTo,
         IsActive = e.IsActive,
         OriginalPrice = e.OriginalPrice,
         Price = e.Price,
         BuyNowUrl = e.BuyNowUrl,
         MarketUrl = e.MarketUrl,
         CouponCode = e.CouponCode,
         Images = e.Images.Select(i => i.Path)
     })
            .GetPagedResultAsync(param?.Skip, param?.Take));
 }
コード例 #2
0
        public async Task <ActionResult <PagedResult <StoreDto> > > GetStores([FromQuery] BasePagingDto request)
        {
            PagedResult <StoreDto> stores = await storeService.GetAllStores(request);

            if (stores == null)
            {
                return(InvalidRequest());
            }

            return(Ok(stores));
        }
コード例 #3
0
        public async Task <ActionResult <PagedResult <BrandDto> > > GetBrands([FromQuery] BasePagingDto request)
        {
            PagedResult <BrandDto> brands =
                await cacheProvider.GetAsync("brands", async() => await brandService.GetAllBrands(request));

            if (brands == null)
            {
                return(InvalidRequest());
            }

            return(Ok(brands));
        }
コード例 #4
0
ファイル: StoreService.cs プロジェクト: kohniuk/DealMeCore
 /// <summary>
 /// Get all stores
 /// </summary>
 /// <param name="pagingParams"></param>
 /// <returns></returns>
 public async Task <PagedResult <StoreDto> > GetAllStores(BasePagingDto pagingParams)
 {
     return(await unitOfWork.GetRepository <Store>()
            .SearchFor(e => !e.IsDisabled.HasValue || e.IsDisabled.HasValue && !e.IsDisabled.Value)
            .Include(e => e.Brand)
            .OrderBy(e => e.Name)
            .Select(e => new StoreDto()
     {
         Name = e.Name,
         Description = e.Description,
         Address = e.Address,
         BrandName = e.Brand.Name
     })
            .GetPagedResultAsync(pagingParams?.Skip, pagingParams?.Take));
 }
コード例 #5
0
 /// <summary>
 /// Get all brands
 /// </summary>
 /// <param name="param"></param>
 /// <returns></returns>
 public async Task <PagedResult <BrandDto> > GetAllBrands(BasePagingDto param)
 {
     return(await unitOfWork.GetRepository <Brand>()
            .SearchFor(e => !e.Disabled.HasValue || e.Disabled.HasValue && !e.Disabled.Value)
            .Include(e => e.Deals)
            .Include(e => e.Stores)
            .OrderBy(e => e.Name)
            .Select(e => new BrandDto
     {
         Name = e.Name,
         Description = e.Description,
         Image = e.Image,
         Disabled = false,
         Url = e.Url,
         TotalCountDeals = e.Deals.Count,
         TotalCountStores = e.Stores.Count
     })
            .GetPagedResultAsync(param?.Skip, param?.Take));
 }
コード例 #6
0
        public static BasePagingDto <ReservationDto> ReservationDtoToPaging(List <ReservationDto> list, int currentPage, int pageSize)
        {
            var result = new BasePagingDto <ReservationDto>();

            var total = list.Count;

            if (total == 0)
            {
                return(result);
            }

            var skip = (currentPage - 1) * pageSize;

            result.Collection = list.Skip(skip).Take(pageSize).ToList();

            result.TotalPage = ((total - 1) / pageSize) + 1;

            result.CurrentPage = currentPage;

            return(result);
        }
コード例 #7
0
        public async Task <ActionResult <PagedResult <BrandDto> > > GetBrandsPagination([FromQuery] BasePagingDto request)
        {
            PagedResult <BrandDto> brands = await brandService.GetAllBrands(request);

            if (brands == null)
            {
                return(InvalidRequest());
            }

            return(Ok(brands));
        }
コード例 #8
0
ファイル: DealsController.cs プロジェクト: kohniuk/DealMeCore
        public async Task <ActionResult <PagedResult <DealDto> > > GetDealsPagination([FromQuery] BasePagingDto request)
        {
            PagedResult <DealDto> deals = await dealService.GetAllDeals(request);

            if (deals == null)
            {
                return(InvalidRequest());
            }

            return(Ok(deals));
        }