public string AddOrder(Order order) { string orderID = dl.GetNewOrderID().ToString(@"000000"); dl.AddOrder(new DO.Order { OrderID = orderID, CustomerID = order.Customer.CustomerID, OrderTime = DateTime.Now, TotalPrice = order.TotalPrice, Paid = order.Paid }); foreach (var item in order.Items) { dl.AddOrderItem(new DO.OrderItem { OrderID = orderID, ItemID = item.ItemID, Price = item.Price, Profit = item.Price - dl.GetCostPrice(item.ItemID) }); dl.SubtractStock(item.ItemID, -1); } return(orderID); }