public async Task CanGetReferralHtmlPages(Gov.Jag.Embc.Public.ViewModels.Referral referral) { var pdfService = new PdfConverter(); var service = new ReferralsService(di, pdfService, cus, null); var fromCommunity = await GetRandomSeededCommunity(); var taskId = await SeedIncident(fromCommunity.Id); var regVM = RegistrationGenerator.GenerateSelf(); regVM.IncidentTask = new Gov.Jag.Embc.Public.ViewModels.IncidentTask { Id = taskId }; var registrationId = await di.CreateEvacueeRegistrationAsync(regVM); referral.EssNumber = registrationId; var referralIds = new List <string>(); var id = await di.CreateReferralAsync(referral); referralIds.Add(id); var printReferrals = new ReferralsToPrint { ReferralIds = referralIds, AddSummary = true }; var content = await service.GetReferralHtmlPagesAsync(printReferrals); Assert.False(string.IsNullOrEmpty(content)); }
public async Task CanGetReferralHtmlPages(Gov.Jag.Embc.Public.ViewModels.Referral referral) { var ctx = EmbcDb; var di = new DataInterface(ctx, Mapper); var pdfService = new PdfConverter(); var service = new ReferralsService(di, pdfService); var incidentTask = await di.CreateIncidentTaskAsync(IncidentTaskGenerator.Generate()); var regVM = RegistrationGenerator.GenerateSelf(); regVM.IncidentTask = incidentTask; var registrationId = await di.CreateEvacueeRegistrationAsync(regVM); referral.EssNumber = registrationId; var referralIds = new List <string>(); var id = await di.CreateReferralAsync(referral); referralIds.Add(id); var printReferrals = new ReferralsToPrint { ReferralIds = referralIds, AddSummary = true }; var content = await service.GetReferralHtmlPagesAsync(printReferrals); Assert.False(string.IsNullOrEmpty(content)); }
public async Task <IActionResult> GetReferralPdfsAsync([FromBody] ReferralsToPrint printReferrals) { var result = await referralsService.GetReferralPdfsAsync(printReferrals); if (result == null) { return(NotFound(new { printReferrals.ReferralIds })); } return(new FileContentResult(result, "application/pdf")); }
public async Task <byte[]> GetReferralPdfsAsync(ReferralsToPrint printReferrals) { var content = await GetReferralHtmlPagesAsync(printReferrals); if (content == null) { return(null); } return(await pdfConverter.ConvertHtmlToPdfAsync(content)); }
public async Task <string> GetReferralHtmlPagesAsync(ReferralsToPrint printReferrals) { var referrals = await dataInterface.GetReferralsAsync(printReferrals.ReferralIds); if (!referrals.Any()) { return(null); } var html = AssembleReferralHtml(referrals, printReferrals.AddSummary); return(html); }
public async Task <IActionResult> GetReferralHtmlAsync([FromBody] ReferralsToPrint printReferrals) { var result = await referralsService.GetReferralHtmlPagesAsync(printReferrals); if (result == null) { return(NotFound(new { printReferrals.ReferralIds })); } return(new ContentResult { ContentType = "text/html", StatusCode = 200, Content = result }); }