Exemplo n.º 1
0
        public async Task <bool> HasAlreadyYielded()
        {
            var buyerId = (await ElizabethBennet.GetElizabethBennet()).UserName;
            var dotNetTShirtItemsIds = (await ShopItems.GetAllItems()).Where(item => item.CatalogBrandId == Brands.DotNet.Id && item.CatalogTypeId == CatalogTypes.TShirt.Id).Select(item => item.Id);

            return(await dbContext.Orders.AnyAsync(order => order.BuyerId == buyerId && order.OrderItems.All(item => dotNetTShirtItemsIds.Contains(item.ItemOrdered.CatalogItemId))));
        }
Exemplo n.º 2
0
        public async Task <bool> HasAlreadyYielded()
        {
            var buyerId      = (await ElizabethBennet.GetElizabethBennet()).UserName;
            var allShopItems = await ShopItems.GetAllItems();

            foreach (var brand in Brands.AllBrands)
            {
                var shopItemsOfBrandIds = allShopItems.Where(item => item.CatalogBrandId == brand.Id).Select(item => item.Id);
                if (!await dbContext.Orders.AnyAsync(
                        order => order.BuyerId == buyerId &&
                        order.OrderItems.Count == Markers.NumberOfItemsPerOrder &&
                        order.OrderItems.All(item => item.Units == Markers.QuantityPerItem && shopItemsOfBrandIds.Contains(item.ItemOrdered.CatalogItemId))))
                {
                    return(false);
                }
            }

            return(true);
        }
Exemplo n.º 3
0
        public async Task Seed()
        {
            var buyerId           = (await ElizabethBennet.GetElizabethBennet()).UserName;
            var dotNetTShirtItems = (await ShopItems.GetAllItems()).Where(item => item.CatalogBrandId == Brands.DotNet.Id && item.CatalogTypeId == CatalogTypes.TShirt.Id);

            // Create temporary basket and fill it with all the items.
            var basket = new Basket(buyerId);

            foreach (var item in dotNetTShirtItems)
            {
                basket.AddItem(item.Id, item.Price, 1);
            }
            basket = await basketRepository.AddAsync(basket);

            await orderService.CreateOrderAsync(basket.Id, ElizabethBennet.GetElizabethsAddress());

            // Delete temporary basket.
            await basketRepository.DeleteAsync(basket);
        }
Exemplo n.º 4
0
        public async Task Seed()
        {
            var buyerId      = (await ElizabethBennet.GetElizabethBennet()).UserName;
            var allShopItems = await ShopItems.GetAllItems();

            // Make a separate order for each brand.
            foreach (var brand in Brands.AllBrands)
            {
                // Create temporary basket and fill it with the items.
                var basket = new Basket(buyerId);
                foreach (var item in allShopItems.Where(item => item.CatalogBrandId == brand.Id).Take(Markers.NumberOfItemsPerOrder))
                {
                    basket.AddItem(item.Id, item.Price, Markers.QuantityPerItem);
                }
                basket = await basketRepository.AddAsync(basket);

                await orderService.CreateOrderAsync(basket.Id, ElizabethBennet.GetElizabethsAddress());

                // Delete temporary basket.
                await basketRepository.DeleteAsync(basket);
            }
        }