public Orders CreateOrder(string productChoice, string taxChoice, DateTime DT, string name, string height, string length) { // adding appropriate file class info into the order class //creating variables var products = new ProductRepo(); var productInfo = products.GrabInfo(productChoice); var taxes = new TaxRepo(); var taxInfo = taxes.GrabInfo(taxChoice); var orderInfo = new Orders(); var ordersFile = new OrderRepo(); var orderCount = ordersFile.GrabDate(DT); int count; if (orderCount.Count() == 0) { count = 0; } else { count = orderCount.Max(c => c.OrderNum); } foreach (var t in taxInfo) { if (t.StateAbrev == taxChoice) { orderInfo.TaxRate = t.TaxRate; orderInfo.State = t.StateAbrev; } } foreach (var p in productInfo) { if (p.ProductType == productChoice) { orderInfo.ProductType = p.ProductType; orderInfo.LaborCostPerSquareFoot = p.LaborCost; orderInfo.CostPerSquareFoot = p.CostSqFeet; } } orderInfo.OrderNum = count + 1; orderInfo.CustomerName = name; orderInfo.Area = CalculateArea(decimal.Parse(height), decimal.Parse(length)); orderInfo.MaterialsCost = MaterialCost(orderInfo.Area, orderInfo.CostPerSquareFoot); orderInfo.LaborCost = LaborCost(orderInfo.Area, orderInfo.LaborCostPerSquareFoot); orderInfo.Tax = TaxCost(orderInfo.MaterialsCost, orderInfo.LaborCost, orderInfo.TaxRate); orderInfo.Total = TotalCost(orderInfo.MaterialsCost, orderInfo.LaborCost, orderInfo.Tax); //var writeOrders = new OrderRepo(); ordersFile.Write(DT, orderInfo); return(orderInfo); }
public List <Orders> CalculateNewValues(IEnumerable <Orders> orders, string userChoice, int ID) { var products = new ProductRepo(); var productInfo = products.GrabInfo(userChoice); var taxes = new TaxRepo(); var taxInfo = taxes.GrabInfo(userChoice); var orderList = orders.ToList(); foreach (var order in orderList) { if (order.OrderNum == ID) { foreach (var t in taxInfo) { if (t.StateAbrev == userChoice) { order.TaxRate = t.TaxRate; order.State = t.StateAbrev; } } foreach (var p in productInfo) { if (p.ProductType == userChoice) { order.ProductType = p.ProductType; order.LaborCostPerSquareFoot = p.LaborCost; order.CostPerSquareFoot = p.CostSqFeet; } } order.MaterialsCost = MaterialCost(order.Area, order.CostPerSquareFoot); order.LaborCost = LaborCost(order.Area, order.LaborCostPerSquareFoot); order.Tax = TaxCost(order.MaterialsCost, order.LaborCost, order.TaxRate); order.Total = TotalCost(order.MaterialsCost, order.LaborCost, order.Tax); } } return(orderList); }