private async Task <string> GenerateHtmlContent(AttendanceLetterModel letter, EducationOrganiztionInformationModel schoolExtraInfo, bool reprint) { // Apply logic by Schoold and by LetterType var studentExtraInfo = await _studentGeneralDataForDnaService.GetById(letter.StudentUsi); var letterType = GetLetterTypeValue(letter.AttendanceLetterTypeId); string template; string pronoun; switch (studentExtraInfo.Sex) { case "Male": pronoun = "his"; break; case "Female": pronoun = "her"; break; default: pronoun = "its"; break; } template = loadPdfAttendanceLetterTemplate(letterType); template = template.Replace("{{StudentName}}", $"{letter.FirstName} {(string.IsNullOrEmpty(letter.MiddleName) ? "" : letter.MiddleName + " ")}{letter.LastSurname}") .Replace("{{StudentUniqueId}}", letter.StudentUniqueId) .Replace("{{LetterType}}", letterType.ToString()) .Replace("{{StudentAddress}}", studentExtraInfo.StreetNumberName) .Replace("{{StudentCity}}", studentExtraInfo.City) .Replace("{{StudentState}}", studentExtraInfo.State) .Replace("{{StudentPostalCode}}", studentExtraInfo.PostalCode) .Replace("{{SchoolAddress}}", schoolExtraInfo.StreetNumberName) .Replace("{{SchoolCity}}", schoolExtraInfo.City) .Replace("{{SchoolState}}", schoolExtraInfo.State) .Replace("{{SchoolPostalCode}}", schoolExtraInfo.PostalCode) .Replace("{{SchoolPhoneNumber}}", schoolExtraInfo.Phone) .Replace("{{SchoolName}}", schoolExtraInfo.NameOfInstitution) .Replace("{{Today}}", $"{letter.ResolutionDate.Value.ToString("MMMM dd, yyyy")}{(reprint? $" Reprint Date: {DateTime.Now.ToString("MMMM dd, yyyy")}" : "")}") .Replace("{{AlertLevel}}", GetAlertLevel(letter.AttendanceLetterTypeId)) .Replace("{{Pronoun}}", pronoun) .Replace("{{SchoolPrincipal}}", $"{schoolExtraInfo.PrincipalFirstName} {schoolExtraInfo.PrincipalLastSurname}"); return(template); }
private async Task <string> GenerateHtmlFromLetters(List <AttendanceLetterModel> letters, EducationOrganiztionInformationModel schoolExtraInfo, bool reprint) { var htmlResult = ""; foreach (var letter in letters) { htmlResult += await GenerateHtmlContent(letter, schoolExtraInfo, reprint); } return(htmlResult); }