Ejemplo n.º 1
0
        private static void DeleteOrder()
        {
            var getInput  = new GetInput();
            var getOutput = new GetOutput();

            int id       = getInput.OrderID();
            var orderDto = getOutput.GetOrderByID(id);

            string input;

            do
            {
                Console.Clear();
                Line();
                MessageInsideBox($"Order Nro. {id}");
                Line();

                PrintOrder(orderDto);

                Line();
                MessageInsideBox("Delete this order(Y/N)?");
                Line();

                input = StandBy();
            } while ((input != "N") && (input != "Y"));

            if (input == "Y")
            {
                var  orderServices = new OrderServices();
                bool success       = orderServices.Delete(orderDto);

                if (success)
                {
                    ReallyImportantMessage("Order deleted.");
                }
                else
                {
                    ReallyImportantMessage("Deletion failed. Can't delete an order from Mexico or France.");
                }
            }
            else
            {
                ReallyImportantMessage("Order kept.");
            }
        }
Ejemplo n.º 2
0
        private static void ReadOrder()
        {
            var getInput  = new GetInput();
            var getOutput = new GetOutput();

            int id              = getInput.OrderID();
            var orderDto        = getOutput.GetOrderByID(id);
            var orderDetailsDto = getOutput.GetOrderDetailsByID(id);

            if ((orderDto == null) || (orderDetailsDto == null))
            {
                ReallyImportantMessage("Error.");
            }

            Console.Clear();
            Line();
            MessageInsideBox($"Order number: {id}");
            Line();

            PrintOrder(orderDto);

            var productServices = new ProductServices();

            int count = 0;

            foreach (var od in orderDetailsDto)
            {
                count++;
                Line();
                MessageInsideBox($"Bill number {count}");
                Line();
                MessageInsideBox($"Product: {productServices.GetProductNameById(od.ProductID)}");
                MessageInsideBox($"Unit price: {String.Format("{0:0.00}", od.UnitPrice)}");
                MessageInsideBox($"Quantity: {od.Quantity}");
                MessageInsideBox($"Discount: {od.Discount}");
                MessageInsideBox($"Subtotal: {String.Format("{0:0.00}", getOutput.Subtotal(od))}");
            }
            Line();
            MessageInsideBox($"Total(with freight): {String.Format("{0:0.00}", getOutput.Total(orderDto))}");

            ImportantMessage("Press any key to continue...");
        }
Ejemplo n.º 3
0
        private static void UpdateOrder()
        {
            var getInput  = new GetInput();
            var getOutput = new GetOutput();

            int id       = getInput.OrderID();
            var orderDto = getOutput.GetOrderByID(id);

            string input;

            do
            {
                Console.Clear();
                Line();
                MessageInsideBox("Select the field you want to update: ");
                Line();
                MessageInsideBox($"1 - Customer ID: {orderDto.CustomerID}");
                MessageInsideBox($"2 - Employee ID: {orderDto.EmployeeID}");
                MessageInsideBox($"3 - Order Date: {orderDto.OrderDate}");
                MessageInsideBox($"4 - Required Date: {orderDto.RequiredDate}");
                MessageInsideBox($"5 - Shipped Date: {orderDto.ShippedDate}");
                MessageInsideBox($"6 - Ship Via: {orderDto.ShipVia}");
                MessageInsideBox($"7 - Freight: {String.Format("{0:0.00}", orderDto.Freight)}");
                MessageInsideBox($"8 - Ship Name: {orderDto.ShipName}");
                MessageInsideBox($"9 - Ship Address: {orderDto.ShipAddress}");
                MessageInsideBox($"10 - Ship City: {orderDto.ShipCity}");
                MessageInsideBox($"11 - Ship Region: {orderDto.ShipRegion}");
                MessageInsideBox($"12 - Ship Postal Code: {orderDto.ShipPostalCode}");
                MessageInsideBox($"13 - Ship Country: {orderDto.ShipCountry}");
                MessageInsideBox("14 - Edit all fields.");
                MessageInsideBox("15 - Save changes.");
                MessageInsideBox("16 - Go back.");
                Line();
                input = StandBy();

                switch (input)
                {
                case "1":
                    orderDto.CustomerID = getInput.CustomerID("Enter the new customed ID: ");
                    break;

                case "2":
                    orderDto.EmployeeID = getInput.EmployeeID();
                    break;

                case "3":
                    orderDto.OrderDate = getInput.Date("Enter the new order date: ");
                    break;

                case "4":
                    orderDto.RequiredDate = getInput.Date("Enter the new required date: ");
                    break;

                case "5":
                    orderDto.ShippedDate = getInput.Date("Enter the new shipped date: ");
                    break;

                case "6":
                    orderDto.ShipVia = getInput.ShipVia("Enter the new ship via: ");
                    break;

                case "7":
                    orderDto.Freight = getInput.PositiveOrZeroDecimal("Enter the new freight: ");
                    break;

                case "8":
                    orderDto.ShipName = getInput.ValidString("Enter the new ship name: ", 40);
                    break;

                case "9":
                    orderDto.ShipAddress = getInput.ValidString("Enter the new ship address: ", 60);
                    break;

                case "10":
                    orderDto.ShipCity = getInput.ValidString("Enter the new ship city: ", 15);
                    break;

                case "11":
                    orderDto.ShipRegion = getInput.ValidString("Enter the new ship region: ", 15);
                    break;

                case "12":
                    orderDto.ShipPostalCode = getInput.ValidString("Enter the new ship postal code: ", 10);
                    break;

                case "13":
                    orderDto.ShipCountry = getInput.ValidString("Enter the new ship country: ", 15);
                    break;

                case "14":
                    orderDto.CustomerID     = getInput.CustomerID("Enter the new customed ID: ");
                    orderDto.EmployeeID     = getInput.EmployeeID();
                    orderDto.OrderDate      = getInput.Date("Enter the new order date: ");
                    orderDto.RequiredDate   = getInput.Date("Enter the new required date: ");
                    orderDto.ShippedDate    = getInput.Date("Enter the new shipped date: ");
                    orderDto.ShipVia        = getInput.ShipVia("Enter the new ship via: ");
                    orderDto.Freight        = getInput.PositiveOrZeroDecimal("Enter the new freight: ");
                    orderDto.ShipName       = getInput.ValidString("Enter the new ship name: ", 40);
                    orderDto.ShipAddress    = getInput.ValidString("Enter the new ship address: ", 60);
                    orderDto.ShipCity       = getInput.ValidString("Enter the new ship city: ", 15);
                    orderDto.ShipRegion     = getInput.ValidString("Enter the new ship region: ", 15);
                    orderDto.ShipPostalCode = getInput.ValidString("Enter the new ship postal code: ", 10);
                    orderDto.ShipCountry    = getInput.ValidString("Enter the new ship country: ", 15);
                    break;

                case "15":
                    var orderServices = new OrderServices();
                    orderServices.Update(orderDto);
                    ReallyImportantMessage("Changes saved");
                    break;

                case "16":
                    break;

                default:
                    ReallyImportantMessage("Invalid field. ");
                    break;
                }
            } while ((input != "15") && (input != "16"));
        }