private string GetEmailBody(Student student, Requirements emailRequirements) { var sb = new StringBuilder(); sb.Append(GetHeader(student, emailRequirements)); if (emailRequirements.HasFlag(Requirements.Fbi)) { sb.Append(GetTemplate(FbiTemplate)); } if (emailRequirements.HasFlag(Requirements.Fcsr)) { sb.Append(GetTemplate(FcsrTemplate)); } if (emailRequirements.HasFlag(Requirements.Liab)) { sb.Append(GetTemplate(LiabTemplate)); } if (emailRequirements.HasFlag(Requirements.Tb)) { sb.Append(GetTemplate(TbTemplate)); } sb.Append(GetTemplate(FooterTemplate)); return sb.ToString(); }
public bool Validate(string password) { var reqStat = new Dictionary <PasswordRequirement, bool>(); if (MinLength.HasValue) { if (password.Length < MinLength.Value) { return(false); } } if (Requirements.HasFlag(PasswordRequirement.Lower)) { reqStat.Add(PasswordRequirement.Lower, Regex.IsMatch(password, "^(?=.*[a-z])")); } if (Requirements.HasFlag(PasswordRequirement.Upper)) { reqStat.Add(PasswordRequirement.Upper, Regex.IsMatch(password, "^(?=.*[A-Z])")); } if (Requirements.HasFlag(PasswordRequirement.Numeric)) { reqStat.Add(PasswordRequirement.Numeric, Regex.IsMatch(password, "^(?=.*[0-9])")); } if (Requirements.HasFlag(PasswordRequirement.SpecialCharacter)) { reqStat.Add(PasswordRequirement.SpecialCharacter, Regex.IsMatch(password, "^(?=.*[^a-zA-Z0-9])")); } if (MinRequirements.HasValue) { return(reqStat.Count(x => x.Value) >= MinRequirements.Value); } return(reqStat.All(x => x.Value)); }
public Requirements DetermineEmails(Student student, Requirements requirements, DateTime cutOff) { var emailsNeeded = Requirements.None; if (requirements.HasFlag(Requirements.Fbi)) { if ( !student.FbiExpiration.Split(',') .Aggregate(false, (current, date) => current || IsCleared(date, cutOff))) { emailsNeeded |= Requirements.Fbi; } } if (requirements.HasFlag(Requirements.Fcsr)) { if (string.IsNullOrEmpty(student.FcsrExpiration) || string.IsNullOrEmpty(student.FcsrExpiration.Trim())) { emailsNeeded |= Requirements.Fcsr; } } if (requirements.HasFlag(Requirements.Liab)) { if (!IsCleared(student.LiabExpiration, cutOff)) { emailsNeeded |= Requirements.Liab; } } if (requirements.HasFlag(Requirements.Tb)) { if (!IsCleared(student.TbExpiration, cutOff)) { emailsNeeded |= Requirements.Tb; } } return emailsNeeded; }
public bool IsCleared(Domain.Student student, Requirements requirements) { if (requirements.HasFlag(Requirements.Fbi)) { return IsFbiCleared(student.FbiExpiration); } if (requirements.HasFlag(Requirements.Fcsr)) { return IsFcsrCleared(student.FcsrExpiration); } if (requirements.HasFlag(Requirements.Liab)) { return IsLiabCleared(student.LiabExpiration); } if (requirements.HasFlag(Requirements.Tb)) { return IsTbCleared(student.TbExpiration); } return true; }
private string GetHeader(Student student, Requirements requirements) { GetTemplate(HeaderTemplate); var template = new StringBuilder(Templates[HeaderTemplate.Name]); template .Replace("%student_name%", student.Name) .Replace("%courses%", string.Join(",", student.Courses)) .Replace("%plural_courses%", student.Courses.Count > 1 ? "courses" : "course") .Replace("%class_type%", requirements.HasFlag(Requirements.Practicum) ? "a practicum" : "student teaching") .Replace("%plural_documents%", Convert.ToUInt64(requirements) > 1 ? "documents" : "document"); return template.ToString(); }