Esempio n. 1
0
        public PagingQueryResponse <Product> GetProducts(PagingQueryRequest query)
        {
            var specification = new RetrievableProductSpecification().And(new ProductMatchingInOwnerSpecification(query.UserId));
            var totalCount    = ReadOnlyDataContext.Products.Where(specification.IsSatisfied()).AsNoTracking().Count();

            var result = new PagingQueryResponse <Product>
            {
                PageSize    = query.PageSize,
                CurrentPage = query.PageIndex,
                TotalCount  = totalCount,
                Result      = DataContext.Products
                              .Where(specification.IsSatisfied())
                              .Include(c => c.ProductPictures)
                              .Include(c => c.Stores)
                              .Include(c => c.ProductBrand)
                              .Include(c => c.ProductTags)
                              .Include(c => c.ProductSizes)
                              .Include(c => c.ProductColors)
                              .Include(c => c.ProductComments)
                              .OrderByDescending(c => c.CreationDate)
                              .Skip((query.PageIndex - 1) * query.PageSize).Take(query.PageSize).ToList()
            };

            return(result);
        }
Esempio n. 2
0
        public PagingQueryResponse <Product> GetDiscountedProductsOfACategory(PagingQueryRequest query, string category, Guid storeId)
        {
            var specification =
                new RetrievableProductSpecification();
            //  .And(new DiscountsMatchingInCategorySpecification(category));

            var totalCount = ReadOnlyDataContext.Products.Where(specification.IsSatisfied()).AsNoTracking().Count();

            var result = new PagingQueryResponse <Product>
            {
                PageSize    = query.PageSize,
                CurrentPage = query.PageIndex,
                TotalCount  = totalCount,
                Result      = DataContext.Products.
                              Where(specification.IsSatisfied())
                              .Include(c => c.ProductPictures)
                              .Include(c => c.ProductTags)
                              .Include(c => c.ProductSizes)
                              .Include(c => c.ProductColors)
                              .OrderByDescending(c => c.CreationDate)
                              .Skip((query.PageIndex - 1) * query.PageSize).Take(query.PageSize).ToList()
            };

            return(result);
        }
Esempio n. 3
0
 public UnauthorizedBasket GetBasketItems(PagingQueryRequest query, Guid cookieId)
 {
     //ToDo Paging
     return(DataContext.UnauthorizedBaskets.Where(d => d.CookieId == cookieId)
            .Include(c => c.BasketItems)
            .Include(c => c.BasketItems.Select(r => r.Product))
            .SingleOrDefault());
 }
Esempio n. 4
0
        public Basket GetBasketItems(PagingQueryRequest query)
        {
            //ToDo Paging
            var specification = new BasketMatchingInOwnerSpecification(query.UserId);

            return(DataContext.Baskets.Where(specification.IsSatisfied())
                   .Include(c => c.BasketItems)
                   .Include(c => c.BasketItems.Select(r => r.Product))
                   .SingleOrDefault());
        }
Esempio n. 5
0
        public PagingQueryResponse <Banner> GetActiveBanners(PagingQueryRequest query)
        {
            var specification = new RetrievableBannerSpecificaion().And(new BannersMatchingInActivitySpecification()).And(new BannersMatchingInConfirmedSpecification());
            var totalCount    = ReadOnlyDataContext.Banners.Where(specification.IsSatisfied()).AsNoTracking().Count();

            var result = new PagingQueryResponse <Banner>
            {
                PageSize    = query.PageSize,
                CurrentPage = query.PageIndex,
                TotalCount  = totalCount,
                Result      = DataContext.Banners.Where(specification.IsSatisfied())
                              .Include(p => p.Picture).OrderByDescending(f => f.CreationDate)
                              .Skip((query.PageIndex - 1) * query.PageSize).Take(query.PageSize).ToList()
            };

            return(result);
        }
Esempio n. 6
0
        public PagingQueryResponse <Order> GetCancelledOrders(PagingQueryRequest query)
        {
            var specification = new OrderMatchingInOwnerSpecification(query.UserId).And(new OrderMatchingInCancelledStatusSpecification());
            var totalCount    = ReadOnlyDataContext.Orders.Where(specification.IsSatisfied());

            var result = new PagingQueryResponse <Order>
            {
                PageSize    = query.PageSize,
                CurrentPage = query.PageIndex,
                TotalCount  = totalCount.Count(),
                Result      = DataContext.Orders
                              .Where(specification.IsSatisfied()).OrderByDescending(c => c.CreationDate)
                              .Skip((query.PageIndex - 1) * query.PageSize).Take(query.PageSize).ToList()
            };

            return(result);
        }
        public PagingQueryResponse <GiftDesk> GetGiftDesks(PagingQueryRequest query)
        {
            var specification = new RetrievableGiftDeskSpecification();
            var totalCount    = ReadOnlyDataContext.GiftDesks.Where(specification.IsSatisfied()).AsNoTracking().Count();

            var result = new PagingQueryResponse <GiftDesk>
            {
                PageSize    = query.PageSize,
                CurrentPage = query.PageIndex,
                TotalCount  = totalCount,
                Result      = DataContext.GiftDesks
                              .Where(specification.IsSatisfied())
                              .OrderByDescending(c => c.CreationDate)
                              .Skip((query.PageIndex - 1) * query.PageSize).Take(query.PageSize).ToList()
            };

            return(result);
        }
Esempio n. 8
0
        public PagingQueryResponse <Discount> GetAllAactiveDiscounts(PagingQueryRequest query, Guid storeId)
        {
            var specification = new RetrievableDiscountSpecification().And(new DiscountsMatchingInActivitySpecification()).And(new DiscountMatchingInStoreSpecification(storeId));
            var totalCount    = ReadOnlyDataContext.Discounts.Where(specification.IsSatisfied()).AsNoTracking().Count();

            var result = new PagingQueryResponse <Discount>
            {
                PageSize    = query.PageSize,
                CurrentPage = query.PageIndex,
                TotalCount  = totalCount,
                Result      = DataContext.Discounts.
                              Where(specification.IsSatisfied())
                              .OrderByDescending(c => c.CreationDate)
                              .Skip((query.PageIndex - 1) * query.PageSize).Take(query.PageSize).ToList()
            };

            return(result);
        }
Esempio n. 9
0
        public PagingQueryResponse <Payment> GetPaymentHistory(PagingQueryRequest query)
        {
            var specification = new RetrievablePaymentSpecification().And(new PaymentMatchingInOwnerSpecification(query.UserId));
            var totalCount    = ReadOnlyDataContext.Payments.Where(specification.IsSatisfied()).AsNoTracking().Count();

            var result = new PagingQueryResponse <Payment>
            {
                PageSize    = query.PageSize,
                CurrentPage = query.PageIndex,
                TotalCount  = totalCount,
                Result      = DataContext.Payments
                              .Where(specification.IsSatisfied())
                              .OrderByDescending(c => c.CreationDate)
                              .Skip((query.PageIndex - 1) * query.PageSize).Take(query.PageSize).ToList()
            };

            return(result);
        }
        public PagingQueryResponse <Favorite> GetUserFavorites(PagingQueryRequest query)
        {
            var totalCount = ReadOnlyDataContext.Favorites.Where(f => f.Users.Any(c => c.Id == query.UserId)).AsNoTracking().Count();

            var result = new PagingQueryResponse <Favorite>
            {
                PageSize    = query.PageSize,
                CurrentPage = query.PageIndex,
                TotalCount  = totalCount,
                Result      = DataContext.Favorites.
                              Where(f => f.Users.Any(c => c.Id == query.UserId))
                              .Include(f => f.Products)
                              .Include(f => f.Stores)
                              .OrderByDescending(c => c.CreationDate)
                              .Skip((query.PageIndex - 1) * query.PageSize).Take(query.PageSize).ToList()
            };

            return(result);
        }
Esempio n. 11
0
        public PagingQueryResponse <Product> GetMostvisitedProducts(PagingQueryRequest query)
        {
            var specification = new RetrievableProductSpecification();
            var totalCount    = ReadOnlyDataContext.Products.Where(specification.IsSatisfied()).AsNoTracking().Count();

            var result = new PagingQueryResponse <Product>
            {
                PageSize    = query.PageSize,
                CurrentPage = query.PageIndex,
                TotalCount  = totalCount,
                Result      = DataContext.Products
                              .Where(specification.IsSatisfied())
                              .OrderByDescending(c => c.VisitCount)
                              .Include(c => c.ProductPictures)
                              .Skip((query.PageIndex - 1) * query.PageSize).Take(query.PageSize).ToList()
            };

            return(result);
        }
Esempio n. 12
0
        public PagingQueryResponse <Store> GetInactiveStores(PagingQueryRequest query)
        {
            var specificaion = new StoreMatchingInInactivitySpecification().And(new StoreMatchingInOwnerSpecificaion(query.UserId));
            var totalCount   = DataContext.Stores.AsNoTracking().Count(specificaion.IsSatisfied());

            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);
        }
        public PagingQueryResponse <User> GetInactiveUsers(PagingQueryRequest query)
        {
            var specification = new MatchingInInactivityUserSpecification(query.Keyword);
            var totalCount    = ReadOnlyDataContext.Users.Where(specification.IsSatisfied()).AsNoTracking().Count();

            var result = new PagingQueryResponse <User>
            {
                PageSize    = query.PageSize,
                CurrentPage = query.PageIndex,
                TotalCount  = totalCount,
                Result      = ReadOnlyDataContext.Users
                              .Where(specification.IsSatisfied())
                              .Include(c => c.Profile)
                              .OrderByDescending(c => c.CreationDate)
                              .Skip((query.PageIndex - 1) * query.PageSize)
                              .Take(query.PageSize).ToList()
            };

            return(result);
        }
Esempio n. 14
0
        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);
        }
Esempio n. 15
0
        public PagingQueryResponse <Product> SearchInProducts(PagingQueryRequest query, string category)
        {
            var specification = new RetrievableProductSpecification();
            var totalCount    = ReadOnlyDataContext.Products.Where(specification.IsSatisfied()).AsNoTracking().Count();

            var result = new PagingQueryResponse <Product>
            {
                PageSize    = query.PageSize,
                CurrentPage = query.PageIndex,
                TotalCount  = totalCount,
                Result      = string.IsNullOrWhiteSpace(query.Keyword)
                ? DataContext.Products.Where(t => t.IsDeleted == false &&
                                             t.ProductCategory.Name == category).ToList()

                   : DataContext.Products.Where(t => t.IsDeleted == false && t.Name.Contains(query.Keyword) &&
                                                t.ProductCategory.Name == category).ToList()
                              .OrderByDescending(f => f.CreationDate)
                              .Skip((query.PageIndex - 1) * query.PageSize).Take(query.PageSize).ToList()
            };

            return(result);
        }
Esempio n. 16
0
        public PagingQueryResponse <Product> GetProductsBySize(PagingQueryRequest query, string category, string size)
        {
            var specification = new RetrievableProductSpecification().And(new ProductsMatchingInSizeSpecification(category, size));
            var totalCount    = ReadOnlyDataContext.Products.Where(specification.IsSatisfied()).AsNoTracking().Count();

            var result = new PagingQueryResponse <Product>
            {
                PageSize    = query.PageSize,
                CurrentPage = query.PageIndex,
                TotalCount  = totalCount,
                Result      = DataContext.Products
                              .Where(specification.IsSatisfied())
                              .Include(p => p.ProductSizes.Where(c => c.Name == size))
                              .Include(c => c.ProductPictures)
                              .Include(c => c.ProductBrand)
                              .Include(c => c.ProductTags)
                              .Include(c => c.ProductColors)
                              .OrderByDescending(f => f.CreationDate)
                              .Skip((query.PageIndex - 1) * query.PageSize).Take(query.PageSize).ToList()
            };

            return(result);
        }
Esempio n. 17
0
 public PagingQueryResponse <Product> GetDiscountedProductsOfABrand(PagingQueryRequest query, Guid storeId)
 {
     throw new NotImplementedException();
 }
Esempio n. 18
0
 public PagingQueryResponse <ProductTag> GetDiscountedTags(PagingQueryRequest query, Guid storeId)
 {
     throw new NotImplementedException();
 }