Ejemplo n.º 1
0
        public void CalculateValues(Order newOrder, Product product)
        {
            newOrder.MaterialCost = newOrder.Area*newOrder.CostPerSquareFoot;

            newOrder.LaborCost = newOrder.Area*newOrder.LaborCostPerSquareFoot;

            newOrder.Tax = newOrder.TaxRate*newOrder.MaterialCost*.01M;

            newOrder.Total = newOrder.MaterialCost + newOrder.LaborCost + newOrder.Tax;
        }
Ejemplo n.º 2
0
 public void AddOrder(Order newOrder, Product chosenProduct, TaxRate taxRateForCustomerState, string orderDate)
 {
     //Calculates the fields necessary to store in the Order
     newOrder.CostPerSquareFoot = chosenProduct.CostPerSquareFoot;
     newOrder.MaterialCost = newOrder.CostPerSquareFoot*newOrder.Area;
     newOrder.LaborCost = newOrder.Area * chosenProduct.LaborCostPerSquareFoot;
     newOrder.Tax = (newOrder.LaborCost + newOrder.MaterialCost) * taxRateForCustomerState.TaxPercent;
     newOrder.Total = newOrder.LaborCost + newOrder.MaterialCost + newOrder.Tax;
     newOrder.LaborCostPerSquareFoot = chosenProduct.LaborCostPerSquareFoot;
 }
Ejemplo n.º 3
0
        private List<Product> ProductListFromArray(string[] allLines)
        {
            var products = new List<Product>();
            foreach (var line in allLines.Skip(1))
            {
                string[] columns = line.Split('|');
                var productInfo = new Product();

                productInfo.ProductType = columns[0];
                productInfo.CostPerSqauareFoot = decimal.Parse(columns[1]);
                productInfo.LaborCostPerSquareFoot = decimal.Parse(columns[2]);
                products.Add(productInfo);
            }
            return products;
        }
         public List<Product> GetAllProducts()
         {
             List<Product> prodList = new List<Product>();
             string[] allLines = File.ReadAllLines("Products.txt");
             foreach (var line in allLines.Skip(1))
             {
                 string[] columns = line.Split('|');
                 var productInfo = new Product();

                 productInfo.ProductType = columns[0];
                 productInfo.CostPerSquareFoot = decimal.Parse(columns[1]);
                 productInfo.LaborCostPerSquareFoot = decimal.Parse(columns[2]);
                 prodList.Add(productInfo);

             }
             return prodList;
             
         }
        private List<Product> ConvertCSVToProducts(string[] productsAsStrings)
        {
            //create a new Orders List
            List<Product> output = new List<Product>();

            for (int i = 1; i < productsAsStrings.Length; i++)
            {
                if (!string.IsNullOrEmpty(productsAsStrings[i]))
                {
                    //set up a new array that splits the row based on ","
                    string[] newRow = productsAsStrings[i].Split(',');

                    Product prod = new Product();

                    prod.ProductType = newRow[0];
                    prod.CostPerSquareFoot = decimal.Parse(newRow[1]);
                    prod.LaborCostPerSquareFoot = decimal.Parse(newRow[2]);

                    output.Add(prod);

                }
            }
            return output;
        }