예제 #1
0
        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);
        }
예제 #2
0
 private Persistence.Models.AttendanceLetters MapAttendanceLetterModelToEntity(AttendanceLetterModel model)
 {
     return(new Persistence.Models.AttendanceLetters
     {
         AttendanceLetterStatusId = model.AttendanceLetterStatusId,
         AttendanceLetterId = model.AttendanceLetterId,
         AttendanceLetterTypeId = model.AttendanceLetterTypeId,
         ClassPeriodName = model.ClassPeriodName,
         FirstAbsence = model.FirstAbsence,
         LastAbsence = model.LastAbsence,
         UserLastSurname = model.UserLastSurname,
         UserCreatedUniqueId = model.UserCreatedUniqueId,
         UserFirstName = model.UserFirstName,
         UserRole = model.UserRole,
         FirstName = model.FirstName,
         LastSurname = model.LastSurname,
         Id = model.Id,
         CreateDate = model.CreateDate,
         MiddleName = model.MiddleName,
         SchoolId = model.SchoolId,
         StudentUniqueId = model.StudentUniqueId,
         GradeLevel = model.GradeLevel,
         SchoolYear = model.SchoolYear,
         ResolutionDate = model.ResolutionDate,
         Comments = model.Comments,
     });
 }