示例#1
0
        private static void CreateOrder()
        {
            var getInput    = new GetInput();
            var newOrderDTO = new OrderDTO
            {
                CustomerID     = getInput.CustomerID("Please enter the customer ID: "),
                EmployeeID     = getInput.EmployeeID(),
                OrderDate      = getInput.Date("Please enter the order date: "),
                RequiredDate   = getInput.Date("Please enter the required date: "),
                ShippedDate    = getInput.Date("Please enter the shipped date: "),
                ShipVia        = getInput.ShipVia("Please enter the ship via: "),
                Freight        = getInput.PositiveOrZeroDecimal("Please enter the freight: "),
                ShipName       = getInput.ValidString("Please enter the ship name: ", 40),
                ShipAddress    = getInput.ValidString("Please enter the ship address: ", 60),
                ShipCity       = getInput.ValidString("Please enter the ship city: ", 15),
                ShipRegion     = getInput.ValidString("Please enter the ship region: ", 15),
                ShipPostalCode = getInput.ValidString("Please enter the ship postal code: ", 10),
                ShipCountry    = getInput.ValidString("Please enter the ship country: ", 15),
            };

            var orderServices = new OrderServices();

            newOrderDTO.OrderID = orderServices.Create(newOrderDTO);

            getInput.OrderDetails(newOrderDTO.OrderID);

            var getOutput = new GetOutput();
            var amount    = getOutput.Total(newOrderDTO);

            ReallyImportantMessage($"Orden Id {newOrderDTO.OrderID} con importe {String.Format("{0:0.00}", amount)} se ha creado correctamente.");
        }
示例#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...");
        }