using System; using System.Collections.Generic; using System.Linq; using System.Reflection; using System.Text; namespace OFBButte.Entities { public class MissionarySupport { public int Id { get; set; } public string Name { get; set; } public string HomePhone { get; set; } public string CellPhone { get; set; } public string FieldPhone { get; set; } public string WifesName { get; set; } public ICollection Children { get; set; } public string Testimony { get; set; } public string CallToField { get; set; } public string SendingChurch { get; set; } public string FieldOfService { get; set; } public string Plans { get; set; } public string EvaluationOfNationals { get; set; } public string TimeInCountry { get; set; } public string CorrectWrongOfAnotherMissionary { get; set; } public string FinancialStatementPrevYear { get; set; } public string CurrentMonthlySupport { get; set; } public string MonthlySupportNeeded { get; set; } public string RestAndRelaxation { get; set; } public string AloneOrTeam { get; set; } public ChildrenSchool ChildrenSchool { get; set; } public bool Dance { get; set; } public bool WorldlyMusic { get; set; } public bool MovieTheaters { get; set; } public bool Alcohol { get; set; } public bool Smoking { get; set; } public bool MaleHair { get; set; } public FemaleSlacks FemaleSlacks { get; set; } public FemaleShorts FemaleShorts { get; set; } public bool FemaleDressStandard { get; set; } public string SwimmingClothing { get; set; } public string Television { get; set; } public BibleReading DailyBible { get; set; } public double NumberLedToChrist { get; set; } public double NumberWitnessedTo { get; set; } public double NumberWeeklyTracts { get; set; } public string RateOfSuccess { get; set; } public string Predestination { get; set; } public string FellowshipAssociation { get; set; } public ICollection CollegeRecommendations { get; set; } public string AdmittedWrong { get; set; } public bool Divorced { get; set; } public bool GroundsForRemarry { get; set; } public bool MarryADivorcee { get; set; } public bool MasonicLodge { get; set; } public string BibleVersionsUsed { get; set; } public string BibleVersionOpinion { get; set; } public bool ContemporaryMusic { get; set; } public string Charasmaticism { get; set; } public bool Tongues { get; set; } public bool RepentanceNecessary { get; set; } public string RepentanceDefinition { get; set; } public bool Fundamentalist { get; set; } public string BillsOnTime { get; set; } public string LateBills { get; set; } public string LateBillActionTaken { get; set; } public string PotentialHarvest { get; set; } public string HoneyPot { get; set; } public Dictionary ToDictionary() { var properties = GetType().GetProperties(System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public).ToDictionary(p => p.Name, p => p); var props = properties.ToDictionary(p => p.Key, p => p.Value.GetValue(this)?.ToString() ?? ""); props.Add("ChildNames", string.Join("
", Children.Select(c => c.Name))); StringBuilder colleges = new StringBuilder(""); foreach (var college in CollegeRecommendations) { colleges.Append($""); } colleges.Append("
{college.Name}    {college.City}, {college.State}
"); props.Add("Colleges", colleges.ToString()); foreach(var prop in properties) { if (prop.Value.PropertyType == typeof(bool) && props.ContainsKey(prop.Key)) { props[prop.Key] = (bool)prop.Value.GetValue(this) == true ? "Yes" : "No"; } } return props; } private void GenerateHtml() { var props = GetType().GetProperties(System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public).ToDictionary(p => p.Name, p => p.GetValue(this)?.ToString() ?? ""); StringBuilder sb = new StringBuilder(); sb.AppendLine(""); sb.AppendLine(" "); foreach (var p in props) { if (p.Key == "Id" || p.Key == "HoneyPot") continue; sb.AppendLine(" "); sb.AppendLine($" "); sb.AppendLine(" "); sb.AppendLine(" "); sb.AppendLine($" "); sb.AppendLine(" "); } sb.AppendLine(" "); sb.AppendLine("
{p.Key}
{{{{{p.Key}}}}}
"); string str = sb.ToString(); } } }