Beispiel #1
0
        public async Task <ActionResult <byte[]> > GetAccessTermSignable(int enrolleeId, int agreementId)
        {
            var record = await _enrolleeService.GetPermissionsRecordAsync(enrolleeId);

            if (record == null)
            {
                return(NotFound(ApiResponse.Message($"Enrollee not found with id {enrolleeId}")));
            }
            if (!record.ViewableBy(User))
            {
                return(Forbid());
            }

            Agreement agreement = await _agreementService.GetEnrolleeAgreementAsync(enrolleeId, agreementId, true);

            if (agreement == null)
            {
                return(NotFound(ApiResponse.Message($"Agreement not found with id {agreementId} on enrollee with id {enrolleeId}")));
            }

            var html = await _razorConverterService.RenderTemplateToStringAsync(RazorTemplates.Agreements.Pdf, agreement);

            var download = _pdfService.Generate(html);

            return(Ok(ApiResponse.Result(download)));
        }
Beispiel #2
0
        public async Task <string> RenderOrgAgreementHtmlAsync(AgreementType type, string orgName, DateTimeOffset?acceptedDate, bool forPdf)
        {
            RazorTemplate <OrgAgreementRazorViewModel> template = (type, forPdf) switch
            {
                (AgreementType.CommunityPharmacyOrgAgreement, false) => RazorTemplates.OrgAgreements.CommunityPharmacy,
                (AgreementType.CommunityPharmacyOrgAgreement, true) => RazorTemplates.OrgAgreements.CommunityPharmacyPdf,
                (AgreementType.CommunityPracticeOrgAgreement, false) => RazorTemplates.OrgAgreements.CommunityPractice,
                (AgreementType.CommunityPracticeOrgAgreement, true) => RazorTemplates.OrgAgreements.CommunityPracticePdf,
                _ => throw new ArgumentException($"Invalid AgreementType {type} in {nameof(RenderOrgAgreementHtmlAsync)}")
            };

            var displayDate = acceptedDate ?? DateTimeOffset.Now;

            // Converting to BC time here since we aren't localizing this time in the web client
            displayDate = displayDate.ToOffset(new TimeSpan(-7, 0, 0));

            return(await _razorConverterService.RenderTemplateToStringAsync(template, new OrgAgreementRazorViewModel(orgName, displayDate)));
        }
Beispiel #3
0
        private async Task <Pdf> GenerateRegistrationReviewAttachmentAsync(int siteId)
        {
            // TODO use Automapper
            var model = await _context.Sites
                        .Where(s => s.Id == siteId)
                        .Select(s => new SiteRegistrationReviewViewModel
            {
                OrganizationName            = s.Organization.Name,
                OrganizationRegistrationId  = s.Organization.RegistrationId,
                OrganizationDoingBusinessAs = s.Organization.DoingBusinessAs,
                SiteName      = s.DoingBusinessAs,
                SiteAddress   = s.PhysicalAddress,
                BusinessHours = s.BusinessHours.Select(h => new BusinessHourViewModel
                {
                    Day       = h.Day,
                    StartTime = h.StartTime,
                    EndTime   = h.EndTime
                }),
                Vendors = s.SiteVendors.Select(sv => new VendorViewModel
                {
                    Name  = sv.Vendor.Name,
                    Email = sv.Vendor.Email
                }),
                RemoteUsers = s.RemoteUsers.Select(ru => new RemoteUserViewModel
                {
                    FullName       = $"{ru.FirstName} {ru.LastName}",
                    Certifications = ru.RemoteUserCertifications.Select(c => new CertViewModel
                    {
                        CollegeName   = c.College.Name,
                        LicenceNumber = c.LicenseNumber
                    })
                }),
                SigningAuthority = new ContactViewModel
                {
                    JobTitle = s.Provisioner.JobRoleTitle,
                    FullName = $"{s.Provisioner.FirstName} {s.Provisioner.LastName}",
                    Phone    = s.Provisioner.Phone,
                    Fax      = s.Provisioner.Fax,
                    SmsPhone = s.Provisioner.SMSPhone,
                    Email    = s.Provisioner.Email
                },
                AdministratorOfPharmaNet = new ContactViewModel
                {
                    JobTitle = s.AdministratorPharmaNet.JobRoleTitle,
                    FullName = $"{s.AdministratorPharmaNet.FirstName} {s.AdministratorPharmaNet.LastName}",
                    Phone    = s.AdministratorPharmaNet.Phone,
                    Fax      = s.AdministratorPharmaNet.Fax,
                    SmsPhone = s.AdministratorPharmaNet.SMSPhone,
                    Email    = s.AdministratorPharmaNet.Email
                },
                PrivacyOfficer = new ContactViewModel
                {
                    JobTitle = s.PrivacyOfficer.JobRoleTitle,
                    FullName = $"{s.PrivacyOfficer.FirstName} {s.PrivacyOfficer.LastName}",
                    Phone    = s.PrivacyOfficer.Phone,
                    Fax      = s.PrivacyOfficer.Fax,
                    SmsPhone = s.PrivacyOfficer.SMSPhone,
                    Email    = s.PrivacyOfficer.Email
                },
                TechnicalSupport = new ContactViewModel
                {
                    JobTitle = s.TechnicalSupport.JobRoleTitle,
                    FullName = $"{s.TechnicalSupport.FirstName} {s.TechnicalSupport.LastName}",
                    Phone    = s.TechnicalSupport.Phone,
                    Fax      = s.TechnicalSupport.Fax,
                    SmsPhone = s.TechnicalSupport.SMSPhone,
                    Email    = s.TechnicalSupport.Email
                },
            })
                        .SingleAsync();

            var html = await _razorConverterService.RenderTemplateToStringAsync(RazorTemplates.SiteRegistrationReview, model);

            return(new Pdf("SiteRegistrationReview.pdf", _pdfService.Generate(html)));
        }
 public async Task <Email> RenderBusinessLicenceUploadedEmailAsync(string recipientEmail, LinkedEmailViewModel viewModel)
 {
     return(new Email
            (
                from: PrimeEmail,
                to: recipientEmail,
                subject: "Site Business Licence Uploaded",
                body: await _razorConverterService.RenderTemplateToStringAsync(RazorTemplates.Emails.BusinessLicenceUploaded, viewModel)
            ));
 }