Exemplo n.º 1
0
        public IActionResult CreateOrder(string CartId)
        {
            //var cartId = model.ShoppingCart.ShoppingCartId;
            var   cartElements = _order.GetShoppingCartItemsToOrder(CartId);
            Order order        = new Order()
            {
                OrderNumber = _order.NextNumber(),
                OrderedDate = DateTime.Now,
                Status      = "Utworzono"
            };

            _order.AddOrder(order);

            //int OrderId = _order.GetLastId();
            foreach (var item in cartElements)
            {
                OrderLine orderLine = new OrderLine()
                {
                    Amount  = item.Amount,
                    Price   = item.product.Price,
                    Note    = item.Note,
                    Product = item.product,
                    Order   = order
                };
                _order.AddLine(orderLine);
            }
            _order.CalculateOrderTotalPrice(order.Id);
            return(RedirectToAction("FulfillAddress", "Address", new { OrderId = order.Id }));
            //return RedirectToAction("FulfillAddress", "Address");
        }