Esempio n. 1
0
        public async Task ClearCartAsync()
        {
            var shoppingCartItems = _context
                                    .ShoppingCartItems
                                    .Where(s => s.ShoppingCartId == Id);

            _context.ShoppingCartItems.RemoveRange(shoppingCartItems);

            ShoppingCartItems = null; //reset
            await _context.SaveChangesAsync();
        }
Esempio n. 2
0
        public async Task CreateOrderAsync(Order order)
        {
            order.OrderPlacedTime = DateTime.Now;
            await _context.Orders.AddAsync(order);

            var shoppingCartItems = await _shoppingCartService.GetShoppingCartItemsAsync();

            order.OrderTotal = (await _shoppingCartService.GetCartCountAndTotalAmmountAsync()).TotalAmmount;

            await _context.OrderDetails.AddRangeAsync(shoppingCartItems.Select(e => new OrderDetail
            {
                Qty        = e.Qty,
                FavourName = e.Favour.Name,
                OrderId    = order.Id,
                Price      = e.Favour.Price
            }));

            await _context.SaveChangesAsync();
        }
Esempio n. 3
0
 public async Task CompleteAsync() =>
 await _context.SaveChangesAsync();