public async Task <IActionResult> GetSpotReportAsync(int id, [FromQuery] ReportOptionsModel reportOptionsModel) { try { var report = await service.GetSpotReportAsync(id, reportOptionsModel); return(Ok(report)); } catch (Exception ex) { var exceptionResponse = GetExceptionResponse(ex, Request); return(exceptionResponse); } }
public static string GeneratePdf(Inspection inspection, ReportOptionsModel model = null) { if (model == null) { model = new ReportOptionsModel(); } IGeneratePdf pdfMaker = DependencyService.Get <IGeneratePdf>(); string fileName = pdfMaker.Initialize(inspection); int numCommentPages = 0; //draw comment pages if (model.Comments) { foreach (Comment comment in inspection.comments) { numCommentPages++; pdfMaker.CreateCommentPage(comment); if (comment != inspection.comments.Last()) { pdfMaker.NewPage(); } } } //draw question listing List <ReportSection> reportSections = PrepareInspectionForScoring(inspection); if (model.Questions) { pdfMaker.NewPageIfNotEmpty(); foreach (ReportSection section in reportSections) { if (model.ScoredSectionsOnly && section.section.availablePoints == 0) { continue; } pdfMaker.CreateQuestionSection(section); if (section != reportSections.Last()) { pdfMaker.NewPage(); } } } //draw section totals if (model.Totals) { pdfMaker.NewPageIfNotEmpty(); pdfMaker.CreateSectionTotals(); } //draw checklist structure if (model.Structure) { pdfMaker.NewPageIfNotEmpty(); pdfMaker.CreateStructure(); } //draw scoresheet if (model.ScoreSheet) { pdfMaker.NewPageIfNotEmpty(); pdfMaker.CreateScoreSheet(); } //draw scores graph if (model.GraphSheet) { pdfMaker.NewPageIfNotEmpty(); pdfMaker.CreateScoreGraph(); } pdfMaker.Finish(); pdfMaker.StampFooter(numCommentPages); return(fileName); }
public async Task <ReportModel <LodgmentsBookingsModel> > GetReportBySpotAsync(int id, ReportOptionsModel reportOptionsModel) { ReportModel <LodgmentsBookingsModel> report = null; if (reportOptionsModel.Name == this.reportLodgmentsBookingName) { report = await GetLodgmentsBookingsBySpotReportAsync(id, reportOptionsModel); } else { throw new KeyNotFoundException("Reporte inexistente"); } return(report); }
private async Task <ReportModel <LodgmentsBookingsModel> > GetLodgmentsBookingsBySpotReportAsync(int id, ReportOptionsModel reportOptionsModel) { var report = await repository.GetLodgmentsBookingsBySpotReportAsync(id, reportOptionsModel); return(report); }
public async Task <IActionResult> Options([FromForm, Bind(ReportOptionsModelBind)] ReportOptionsModel model) { await _mediator.Send(new UpdateOptionsRequest { Model = model }); return(RedirectToAction(nameof(ProductInfo))); }
public async Task <ReportModel <LodgmentsBookingsModel> > GetSpotReportAsync(int id, ReportOptionsModel reportOptionsModel) { await CheckSpotExists(id); var report = await reportsService.GetReportBySpotAsync(id, reportOptionsModel); return(report); }
public async Task <ReportModel <LodgmentsBookingsModel> > GetLodgmentsBookingsBySpotReportAsync(int id, ReportOptionsModel reportOptionsModel) { try { var report = new ReportModel <LodgmentsBookingsModel>(); IQueryable <Booking> query = bookings.Where(x => x.BookingStatus.Id <= MaxValidBookingStatus && x.CheckIn >= reportOptionsModel.StartDate && x.CheckOut <= reportOptionsModel.EndDate).AsQueryable(); query = query.Where(x => x.Lodgment.SpotId == id); report.Data = await query.GroupBy(p => p.Lodgment.Name) .Select(g => new LodgmentsBookingsModel() { Name = g.Key, Count = g.Count() }) .OrderByDescending(x => x.Count).ToListAsync(); return(report); } catch (Exception e) { throw new WrappedDbException("Error on get lodgments bookings by spot report async", e); } }