public async Task <ActionResult <AccessTerm> > GetAccessTerm(int enrolleeId, int accessTermId) { var enrollee = await _enrolleeService.GetEnrolleeAsync(enrolleeId); if (enrollee == null) { return(NotFound(ApiResponse.Message($"Enrollee not found with id {enrolleeId}"))); } if (!User.CanView(enrollee)) { return(Forbid()); } if (!await _accessTermService.AccessTermExistsOnEnrolleeAsync(accessTermId, enrolleeId)) { return(NotFound(ApiResponse.Message($"Access term not found with id {accessTermId} for enrollee id: {enrolleeId}"))); } AccessTerm accessTerm = await _accessTermService.GetEnrolleesAccessTermAsync(enrolleeId, accessTermId); accessTerm.TermsOfAccess = await _razorConverterService.RenderViewToStringAsync("/Views/TermsOfAccess.cshtml", accessTerm); if (User.IsAdmin()) { await _businessEventService.CreateAdminViewEventAsync(enrollee.Id, "Admin viewing Terms of Access"); } return(Ok(ApiResponse.Result(accessTerm))); }
public async Task <string> RenderOrgAgreementHtmlAsync(AgreementType type, string orgName, DateTimeOffset?acceptedDate, bool forPdf) { string viewName; switch (type) { case AgreementType.CommunityPracticeOrgAgreement: viewName = forPdf ? "/Views/CommunityPracticeOrganizationAgreementPdf.cshtml" : "/Views/CommunityPracticeOrganizationAgreement.cshtml"; break; case AgreementType.CommunityPharmacyOrgAgreement: viewName = forPdf ? "/Views/CommunityPharmacyOrganizationAgreementPdf.cshtml" : "/Views/CommunityPharmacyOrganizationAgreement.cshtml"; break; default: throw new ArgumentException($"Invalid AgreementType {type} in {nameof(RenderOrgAgreementHtmlAsync)}"); } DateTimeOffset 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.RenderViewToStringAsync(viewName, new Tuple <string, DateTimeOffset>(orgName, displayDate))); }
public async Task SendReminderEmailAsync(Enrollee enrollee) { if (!IsValidEmail(enrollee.ContactEmail)) { // TODO Log invalid email, cannot send? return; } string subject = "PRIME Requires your Attention"; string body = await _razorConverterService.RenderViewToStringAsync("/Views/Emails/ReminderEmail.cshtml", new EmailParams()); await Send(PRIME_EMAIL, enrollee.ContactEmail, subject, body); }
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.RenderViewToStringAsync("/Views/TermsOfAccessPdf.cshtml", agreement); var download = _pdfService.Generate(html); return(Ok(ApiResponse.Result(download))); }
public async Task <ActionResult <string> > GetOrganizationAgreement(int organizationId) { var organization = await _organizationService.GetOrganizationAsync(organizationId); if (organization == null) { return(NotFound(ApiResponse.Message($"Organization not found with id {organizationId}"))); } var agreement = await _razorConverterService.RenderViewToStringAsync("/Views/OrganizationAgreement.cshtml", organization); return(Ok(ApiResponse.Result(agreement))); }
public async Task SendReminderEmailAsync(int enrolleeId) { var enrolleeEmail = await _context.Enrollees .Where(e => e.Id == enrolleeId) .Select(e => e.Email) .SingleOrDefaultAsync(); if (!IsValidEmail(enrolleeEmail)) { // TODO Log invalid email, cannot send? return; } string subject = "PRIME Requires your Attention"; string body = await _razorConverterService.RenderViewToStringAsync("/Views/Emails/ReminderEmail.cshtml", new EmailParams()); await Send(PRIME_EMAIL, enrolleeEmail, subject, body); }