Exemplo n.º 1
0
        // Validation complete. Done.

        public DateTime Display()
        {
            var    order = new FileData.OrderRepo();
            string date  = ReadString("Please enter in the date of your order (any format): ");

            DateTime.TryParse(date, out DateTime dt);

            if (dt == null)
            {
                Console.WriteLine("Please enter in a valid input");
            }
            else
            {
                if (DateTime.Now > dt)
                {
                    Console.WriteLine("Please enter in a valid date in the FUTURE");
                }
                else
                {
                    var orders = order.GrabDate(dt);
                    if (orders == null)
                    {
                        Console.WriteLine("Could NOT find the file with the date you have entered.");
                    }
                    else
                    {
                        foreach (var o in orders)
                        {
                            Console.WriteLine($"{o.OrderNum}  {o.CustomerName}  {o.State}  {o.TaxRate}  {o.ProductType}  {o.Area}  {o.CostPerSquareFoot}  {o.LaborCostPerSquareFoot}  {o.MaterialsCost}  {o.LaborCost}  {o.Tax}  {o.Total}");
                        }
                    }
                }
            }
            return(dt);
        }
Exemplo n.º 2
0
        public List <Orders> EditOrder(int ID, DateTime dt, string editChoice, int varToChange)
        {
            if (editChoice == null)
            {
                return(null);
            }
            else
            {
                var order = new FileData.OrderRepo();
                var file  = order.GrabDate(dt);

                var edit   = order.FindByIDAndDate(ID, dt);
                var result = order.EditOrder(file, ID, editChoice, varToChange);

                if (result == null)
                {
                    return(null);
                }
                else
                {
                    var calc = CalculateNewValues(result, editChoice, ID);

                    order.WriteOrders(calc, dt);

                    return(result);
                }
            }
        }
Exemplo n.º 3
0
        public void RemovingOrder(DateTime dt, int ID)
        {
            var order = new FileData.OrderRepo();
            var file  = order.GrabDate(dt);



            foreach (var f in file)
            {
                if (f.OrderNum == ID)
                {
                    var orders = order.FindByIDAndDate(ID, dt);
                    var remove = order.RemoveOrder(file, dt, orders, ID);
                    order.WriteOrders(remove, dt);
                    var testing = order.GrabDate(dt);
                }
            }
        }
Exemplo n.º 4
0
        //Does NOT require any more validation I think, done.

        public void RemoveOrder()
        {
            var file = new FileData.OrderRepo();


            var dt = Display();
            int id = ReadIntInRange("Please enter in the ID of the date you would like to remove: ", 1, 99999999);
            var o  = file.FindByIDAndDate(id, dt);

            if (o != null)
            {
                bool correct = false;
                while (correct == false)
                {
                    Console.Clear();
                    Console.WriteLine($"{o.OrderNum}  {o.CustomerName}  {o.State}  {o.TaxRate}  {o.ProductType}  {o.Area}  {o.CostPerSquareFoot}  {o.LaborCostPerSquareFoot}  {o.MaterialsCost}  {o.LaborCost}  {o.Tax}  {o.Total}");
                    string removeYesorNo = ReadString("Are you sure this is the the ID you would like to remove? (Y/N)");
                    if (removeYesorNo == "Yes" || removeYesorNo == "Y")
                    {
                        Console.WriteLine("You have choosen to delete this entry.");
                        service.RemovingOrder(dt, id);
                        correct = true;
                    }
                    else if (removeYesorNo == "No" || removeYesorNo == "N")
                    {
                        Console.WriteLine("You have choosen to not delete this entry.");
                        correct = true;
                    }
                    else
                    {
                        Console.Clear();
                        Console.WriteLine("Please enter in a valid input.");
                        Console.ReadKey();
                    }
                }
            }
            else
            {
                Console.WriteLine("That id or file does not exist.");
            }
            Console.ReadKey();
        }
Exemplo n.º 5
0
        // NEEDS VALIDATION STILL
        public void EditOrder()
        {
            var dt = Display();

            int ID   = ReadIntInRange("Please enter in the ID you would like to edit: ", 1, 999999999);
            var file = new FileData.OrderRepo();

            var list = file.FindByIDAndDate(ID, dt);

            if (list == null)
            {
                Console.WriteLine("Please enter in a valid ID.");
                Console.ReadKey();
            }
            else
            {
                Console.WriteLine($" 1) Name: {list.CustomerName} \n 2) State: {list.State} \n 3) ProductType: {list.ProductType} \n 4) Area/Dimensions: {list.Area}");

                int    varToChange = ReadIntInRange($"Please enter in the ID of the variable you would like to change: ", 1, 4);
                string userChoice  = ReadString("Please enter in what the new property you would like to be (if blank it will not change): ");


                var editedOrder = service.EditOrder(ID, dt, userChoice, varToChange);
                list = file.FindByIDAndDate(ID, dt);
                if (editedOrder == null)
                {
                    Console.WriteLine("You have chosen to not update any value or what you inputed as a new value was not valid.");
                    Console.ReadKey();
                }
                else
                {
                    Console.WriteLine($"Your updated order values are now as follows:\n Name: {list.CustomerName} \n State: {list.State} \n ProductType: {list.ProductType} \n Area/Dimensions: {list.Area}");
                    Console.ReadKey();
                }
            }
        }