Exemplo n.º 1
0
        private void DisplayInvoice(OrderDTO order)
        {
            List <ProductDTO> products = productService.GetProducts();

            Console.WriteLine("".PadRight(30, '-') + "RECEIPT" + "".PadRight(30, '-'));

            Console.WriteLine();
            Console.WriteLine("Order Number: " + order.Id);
            Console.WriteLine("Date: " + order.CreatedDate.ToString());
            Console.WriteLine();
            Console.WriteLine();

            reportHandler.SetupColumns(30, 10, 30);

            reportHandler.AddColumns("Product", "Price", "Promotion Applied");

            reportHandler.AddColumns('-', "", "", "");

            decimal total = 0;

            foreach (OrderItemDTO orderItem in order.OrderItems)
            {
                ProductDTO product = products.First(p => p.Code == orderItem.ProductCode);

                reportHandler.AddColumns(product.Description, orderItem.Price.ToString("C"),
                                         (orderItem.PromotionApplied ? "Yes" : "No"));

                total += orderItem.Price;
            }

            reportHandler.AddRow();

            reportHandler.AddColumns("Total", total.ToString("C"));

            reportHandler.GenerateReport();
        }