private static Order CreateOrder(List<LineItem> productList, BLHCustomer customer) { Order order = new Order(); order.CustomerNumber = customer.CustomerID; order.FirstName = customer.FirstName; order.LastName = customer.LastName; order.ZipCode = customer.Zip; string productListAsString = CreateProductList(productList); order.ProductList = productListAsString; order.ShippingCost = GetShippingCost(""); order.TotalCost = GetProductTotals(productList) + order.ShippingCost; return order; }
public static string GetSummary(Order order) { if (order == null) { return ""; } string[] productList = order.ProductList.Split(','); string summary = string.Format("Order #:{0,-20}Customer #: {1,-20}\nName: {2}, {3}\nZip Code: {4}\n", order.OrderNumber, order.CustomerNumber, order.LastName, order.FirstName, order.ZipCode); summary += string.Format("{0,-35}{1,-15}{2}\n", "Product Name", "Cost", "Quantity"); for (int i = 0; i < productList.Length - 2; i += 3) { decimal cost; decimal.TryParse(productList[i + 1], out cost); summary += string.Format("{0,-35}{1,-25:C} {2}\n", productList[i], cost, productList[i + 2]); } summary += string.Format("Shipping Cost: {0}\nTotal Cost: {1}", order.ShippingCost, order.TotalCost); return summary; }
/// <summary> /// Create a new Order object. /// </summary> /// <param name="orderNumber">Initial value of the OrderNumber property.</param> /// <param name="customerNumber">Initial value of the CustomerNumber property.</param> /// <param name="firstName">Initial value of the FirstName property.</param> /// <param name="lastName">Initial value of the LastName property.</param> /// <param name="zipCode">Initial value of the ZipCode property.</param> /// <param name="productList">Initial value of the ProductList property.</param> /// <param name="shippingCost">Initial value of the ShippingCost property.</param> /// <param name="totalCost">Initial value of the TotalCost property.</param> public static Order CreateOrder(global::System.Int32 orderNumber, global::System.Int32 customerNumber, global::System.String firstName, global::System.String lastName, global::System.String zipCode, global::System.String productList, global::System.Decimal shippingCost, global::System.Decimal totalCost) { Order order = new Order(); order.OrderNumber = orderNumber; order.CustomerNumber = customerNumber; order.FirstName = firstName; order.LastName = lastName; order.ZipCode = zipCode; order.ProductList = productList; order.ShippingCost = shippingCost; order.TotalCost = totalCost; return order; }
/// <summary> /// Deprecated Method for adding a new object to the Orders EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToOrders(Order order) { base.AddObject("Orders", order); }