private decimal CalculateTotalPrice(OrderModel order, out decimal subTotal) { decimal price = 0M; //depand on the size price += GetPizzaPrice(order.pizzaSize); //add the cost of toppings price += GetToppingsPrice(order.toppings.Count()); //add the cost of crust type price += 2; subTotal = price; //add tax price = price * (1 + taxDictionary[order.province]); return price; }
private OrderItem[] CollectOrderItems(OrderModel order) { OrderItem[] orderItems = new OrderItem[3]; try { OrderItem item1 = new OrderItem(); item1.itemName = order.pizzaSize + " pizza"; item1.quantity = 1; item1.cost = GetPizzaPrice(order.pizzaSize).ToString("C2"); orderItems[0] = item1; OrderItem item2 = new OrderItem(); item2.itemName = "Toppings"; item2.quantity = order.toppings.Count(); item2.cost = GetToppingsPrice(order.toppings.Count()).ToString("C2"); orderItems[1] = item2; OrderItem item3 = new OrderItem(); item3.itemName = "Stuffed Crust"; item3.quantity = 1; item3.cost = "$2.00"; orderItems[2] = item3; } catch (Exception ex) { string s = ex.InnerException.Message; } return orderItems; }
private string[] GenerateOrderStringArray(OrderModel order) { List<string> list = new List<string>(); string sDateTime = DateTime.Now.ToString(); list.Add(sDateTime); string sCustomerName = "Customer Name : " + order.customerName; list.Add(sCustomerName); string sPostalCode = "Postal Code: " + order.postalCode; list.Add(sPostalCode); string sProvince = "Province :" + order.province; list.Add(sProvince); string sCity = "City: " + order.city; list.Add(sCity); string sPhoneNumber = "Phone Number :" + order.telephoneNumber; list.Add(sPhoneNumber); string sEmail = "Email :" + order.email; list.Add(sEmail); string sPizzaSize = "Pizza Siza: " + order.pizzaSize; list.Add(sPizzaSize); string sToppings = "Toppings: "; foreach(var t in order.toppings) { sToppings += t; sToppings += ","; } list.Add(sToppings); string sCrustType = "Crust Type: " + order.crustType; list.Add(sCrustType); return list.ToArray(); }