Ejemplo n.º 1
0
        public async Task <IActionResult> Checkout()
        {
            var cartItems = await _shoppingCartService.GetShoppingCartItemsAsync();

            if (cartItems?.Count() <= 0)
            {
                return(Redirect("/shoppingcart"));
            }
            return(View());
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Index()
        {
            await _shoppingCart.GetShoppingCartItemsAsync();

            var shoppingCartCountTotal = await _shoppingCart.GetCartCountAndTotalAmmountAsync();

            var shoppingCartViewModel = new MShoppingCartViewModel
            {
                ShoppingCart           = _shoppingCart,
                ShoppingCartItemsTotal = shoppingCartCountTotal.ItemCount,
                ShoppingCartTotal      = shoppingCartCountTotal.TotalAmmount,
            };


            return(View(shoppingCartViewModel));
        }
Ejemplo n.º 3
0
        public async Task CreateOrderAsync(MOrder morder)
        {
            morder.OrderPlacedTime = DateTime.Now;
            await _context.MOrders.AddAsync(morder);

            var MshoppingCartItems = await _shoppingCartService.GetShoppingCartItemsAsync();

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

            await _context.MOrderDetails.AddRangeAsync(MshoppingCartItems.Select(e => new MOrderDetail
            {
                Qty         = e.Qty,
                MachineName = e.MachineName,
                OrderId     = morder.Id,
                Price       = e.Machine.Price
            }));

            await _context.SaveChangesAsync();
        }