/// <summary> /// Generates the photo report. /// </summary> /// <returns>The photo report.</returns> /// <param name="inspection">Inspection.</param> private async Task generatePhotoReport(Inspection inspection) { InspectionDetailService inspectionDetailService = new InspectionDetailService(AppDelegate.DatabaseContext); Inspection insObj = inspectionDetailService.GetInspectionDetail(inspection, true); IReportHandler reportHandler = ReportFactory.GetReportHandler(ReportType.TempPhotolog); TempPhotoLogReportPath = reportHandler.GenerateReport("TempPhotoLogReport.pdf", insObj); reportHandler = ReportFactory.GetReportHandler(ReportType.PhotoLog); PhotoLogReportPath = reportHandler.GenerateReport("PhotoLogReport.pdf", insObj); }
public string GenerateReport(string fileName, Inspection inspectionResult) { switch (inspectionResult.pass.ToLower()) { case "pass": reportHandler = ReportFactory.GetReportHandler(ReportType.Pass); break; case "fail": reportHandler = ReportFactory.GetReportHandler(ReportType.Fail); break; } var path = reportHandler.GenerateReport(fileName, inspectionResult); return(path); }
public void DisplayProducts() { List <ProductDTO> products = productService.GetProducts(); Console.WriteLine(); Console.WriteLine("Products:"); Console.WriteLine(); reportHandler.SetupColumns(30, 10, 30); reportHandler.AddColumns("Name", "Code", "Promotion"); reportHandler.AddColumns('-', "", "", ""); foreach (ProductDTO product in products) { string promotionDisplay = string.Empty; if (product.Promotions.Count > 0) { // we assume the service will only return one active promotion (promotions are stored in the DB) PromotionDTO promotion = product.Promotions.First(); if (promotion.PromotionCode == Constants.PromotionType.Discount) { promotionDisplay = String.Format("Buy {0}, Discount Next {1} to {2:P}", promotion.Quantity, promotion.ApplyTo, promotion.Amount); } else if (promotion.PromotionCode == Constants.PromotionType.Price) { promotionDisplay = String.Format("Buy {0} for {1:C}", promotion.Quantity, promotion.Amount); } } reportHandler.AddColumns(product.Description, product.Code, promotionDisplay); } reportHandler.GenerateReport(); }
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(); }