private string FillEmailTemplate(ElementaryEmailModel emailData) { var template = loadEmailTemplate(); var filledTemplate = template.Replace("{{StaffFullName}}", $"{emailData.HomeRoomStaffFirstName} {(string.IsNullOrEmpty(emailData.HomeRoomStaffMiddleName) ? "" : emailData.HomeRoomStaffMiddleName + " ")}{emailData.HomeRoomStaffLastSurname}") .Replace("{{EmailMessage}}", "These following students are assigned to a course you teach, and have been marked absent at least 3 of the past 5 days PRIOR to yesterday.") .Replace("{{TableContent}}", CalculateTableContent(emailData)); return(filledTemplate); }
private string CalculateTableContent(ElementaryEmailModel emailData) { string tablecontent = "<thead style='background: #ffffff;'><tr style='background: #ffffff;'>"; tablecontent += "<th>First Last (name)</th> <th>Student ID</th> <th>Learn Location</th>"; foreach (var day in emailData.Students.FirstOrDefault().AbsencesFromLastWeek) { tablecontent += $"<th>{day.Date.ToString("ddd MMM dd")}</th>"; } tablecontent += "</tr></thead> <tbody style='background: #ffffff;'>"; foreach (var student in emailData.Students) { tablecontent += @$ "<tr style='background: #ffffff;'> <td>{student.StudentFirstName} {student.StudentLastName}</td>