public Order GenerateOrder(DateTime orderDate, string customerName, string state, string productType, decimal area) { Order order = new Order(); order.OrderNumber = 1; //default, data repo will take care of this order.CustomerName = customerName; order.State = state; order.ProductType = productType; order.Area = area; order.OrderDate = orderDate; foreach (Product product in _products.RetrieveProducts()) { if (product.ProductType.ToLower() == order.ProductType.ToLower()) { order.CostPerSquareFoot = product.CostPerSquareFoot; order.LaborCostPerSquareFoot = product.LaborCostPerSquareFoot; } } foreach (Tax tax in _taxes.RetrieveTaxes()) { if (tax.StateAbbreviation.ToLower() == order.State.ToLower()) { order.TaxRate = tax.TaxRate; } } order.MaterialCost = order.Area * order.CostPerSquareFoot; order.LaborCost = order.Area * order.LaborCostPerSquareFoot; order.Tax = (order.MaterialCost + order.LaborCost) * (order.TaxRate / 100); order.Total = order.MaterialCost + order.LaborCost + order.Tax; return(order); }
public OrderManager(IOrderRepository orders, IProductRepository products, ITaxRepository taxes) { _orders = orders; _products = products; _taxes = taxes; Products = _products.RetrieveProducts(); Taxes = _taxes.RetrieveTaxes(); }