Ejemplo n.º 1
0
        public void CreateOrder(Library.PurOrder order)
        {
            decimal orderTotal = 0;

            order.OrderList = new List <Library.OrderList>();

            var cartItems = GetCartItems();

            foreach (var item in cartItems)
            {
                var orderDetail = new Library.OrderList
                {
                    ProductId = item.ProductId,
                    OrderId   = order.OrderId,
                    UnitPrice = Convert.ToDouble(item.Product.Cost),
                    Qty       = item.Qty
                };

                orderTotal += (item.Qty * Convert.ToDecimal(item.Product.Cost));
                order.OrderList.Add(orderDetail);

                //  _dbContext.OrderList.Add(orderDetail);
            }

            order.Total = orderTotal;


            _dbContext.SaveChanges();

            //EmptyCart();
        }
Ejemplo n.º 2
0
 public static Entities.OrderList Map(Library.OrderList orderlist) => new Entities.OrderList
 {
     OrderListId = orderlist.OrderListId,
     OrderId     = orderlist.OrderId,
     ProductId   = orderlist.ProductId,
     UnitPrice   = Convert.ToDecimal(orderlist.UnitPrice),
     Qty         = orderlist.Qty
 };