Ejemplo n.º 1
0
        /// <summary>
        /// Saving to a text file what is in a order list
        /// </summary>
        private void SaveOrders(List <FlooringOrder> orders, string datestring)
        {
            string       filepath = $"Orders_{datestring}.txt";
            StreamWriter sw       = null;

            try
            {
                sw = new StreamWriter(filepath);
                sw.WriteLine("OrderNumber||date||CustomerName||State||TaxRate||ProductType||Area||CostPerSquareFoot||LaborCostPerSquareFoot||MaterialCost||LaborCost||Tax||Total");

                foreach (FlooringOrder order in orders)
                {
                    sw.WriteLine(OrderMapper.ToString(order));
                    sw.Flush();
                }
            }
            //catch (Exception e)
            //{
            //    Console.WriteLine("Something went wrong");
            //}
            finally
            {
                if (sw != null)
                {
                    sw.Close();
                }
            }
        }
        private void SaveOrder(OrderResponse response)
        {
            StreamWriter sw = null;


            try
            {
                sw = new StreamWriter($"Orders_{response.DateString}.txt");

                sw.Write("OrderNumber::CustomerName::State::TaxRate::ProductType::Area::CostPerSquareFoot::LaborCostPerSquareFoot::MaterialCost::LaborCost::Tax::Total");

                foreach (Order order in response.Orders)
                {
                    sw.Write("\n" + OrderMapper.ToString(order));
                    sw.Flush();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Something went wrong.");
            }
            finally
            {
                if (sw != null)
                {
                    sw.Close();
                }
            }
        }
Ejemplo n.º 3
0
        private void SaveOrder(List <FlooringOrder> order, string date)
        {
            string       filepath = $"Orders_{date}.txt";
            StreamWriter sw       = null;

            try
            {
                sw = new StreamWriter(filepath);
                sw.WriteLine("OrderNumber||date||CustomerName||State||TaxRate||ProductType||Area||CostPerSquareFoot||LaborCostPerSquareFoot||MaterialCost||LaborCost||Tax||Total");

                foreach (FlooringOrder Order in order)
                {
                    sw.WriteLine(OrderMapper.ToString(Order));
                    sw.Flush();
                }
            }
            finally
            {
                if (sw != null)
                {
                    sw.Close();
                }
            }
        }