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); }
//TODO: I used auto-fix to add the private line above. Why is it required to set numProducts? public OrderManager(IOrderRepo orderRepository) { _orderRepository = orderRepository; //TODO: Search for _orderRepository to see how it's used and ask if I still don't know. // Load all tax Info List <StateTax> Taxes = new List <StateTax>(); Taxes = TaxRepo.ReadFile(); //Load all Product Info List <Product> Products = new List <Product>(); Products = ProductRepo.ReadFile(); int numProducts = Products.Count; List <Order> allOrders = new List <Order>(); }
public Response FetchStateTaxInfo(string stateAbbreviation) { var stateTaxRepo = new TaxRepo(); var response = new Response(); var stateTaxInfo = stateTaxRepo.GetStateTaxInfo(stateAbbreviation); if (stateTaxInfo == null) { response.Success = false; response.Message = "That state is not in our database."; } else { response.Success = true; response.StateTaxInfo = stateTaxInfo; } return(response); }
private static Order CalcRestofOrder(Order orderFromUsr) { //Keep lInq statements here. // Move others to the getter. //Order completedOrder = new Order(); OrderTestRepo2 orderRepo = new OrderTestRepo2(); //List<Order> allCrntOrders = orderRepo.LoadOrders(); List <StateTax> allTaxInfo = TaxRepo.ReadFile(); List <Product> allPrducts = ProductRepo.ReadFile(); StateTax stateTax = allTaxInfo.FirstOrDefault(t => t.StateAbrev == orderFromUsr.State); orderFromUsr.TaxRate = stateTax.Tax; Product crntProd = allPrducts.FirstOrDefault(p => p.ProductType == orderFromUsr.ProductType); orderFromUsr.CostPerSquareFoot = crntProd.CostPerSquareFoot; orderFromUsr.LaborCostPerSquareFoot = crntProd.LaborCostPerSquareFoot; return(orderFromUsr); }
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); }
public static string AskForNewStateAbbr() { List <StateTax> TaxList = TaxRepo.ReadFile(); foreach (StateTax tax in TaxList) { Console.WriteLine(" " + (TaxList.IndexOf(tax) + 1) + ". " + tax.StateName); } Console.WriteLine("Type the number of the state."); int userNumChoice = CommonIO.GetIntFromUser(0, TaxList.Count, -1); if (userNumChoice == -1) { // Users choose zero when selecting no state, which gets set to -1 in GetIntFromUser using offset return(null); } else { StateTax SelectedState = TaxList.ElementAt(userNumChoice); return(SelectedState.StateAbrev); } }
public List <Tax> FetchListOfStates() { var stateTaxRepo = new TaxRepo(); return(stateTaxRepo.GetTaxesList()); }
public TaxController() { _tRepo = new TaxRepo(); }