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(); }
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 };