//******************************************************************************** private string DisplayMesh(GroupViewModel group) { StringBuilder sb = new StringBuilder(); sb.AppendLine(string.Format("\n******Group {0} ******", group.GroupName)); sb.AppendLine(string.Format("\n* Members")); foreach (var member in group.Members) { string mName = member.CommonName; var memberBirthday = member.GetBirthday(); sb.AppendLine(string.Format("\nGroup Member: {0}", mName)); if (member.Details != null) { sb.AppendLine(string.Format(" Details")); foreach (DetailViewModel memberDetail in member.Details) { sb.AppendLine(string.Format(" {0}", memberDetail.DetailTypeText)); if (memberDetail.StartDate.HasValue) { sb.AppendLine(string.Format(" {0} {1}", memberDetail.DetailTypeStartText, memberDetail.StartDate.ToString())); } if (memberDetail.EndDate.HasValue) { sb.AppendLine(string.Format(" {0} {1}", memberDetail.DetailTypeEndText, memberDetail.EndDate.ToString())); } sb.AppendLine(string.Format(" {0}", memberDetail.Story)); } } if (member.Relationships != null) { sb.AppendLine("\n Relationships"); foreach (CombinedRelationshipReadModel rel in member.Relationships) { var self = rel.RelationshipMembers.First(x => x.MemberId == member.Id); var selfRelationshipTypeCode = self.MemberRelationshipTypeCode; var other = rel.RelationshipMembers.First(x => x.MemberId != member.Id); var otherMember = group.Members.First(x => x.Id == other.MemberId); string relName = otherMember.CommonName; DetailViewModel relBirthday = otherMember.GetBirthday(); if (memberBirthday.StartDate <= relBirthday.StartDate) { string timeYounger = Analytics.GetTimeBetween(memberBirthday.StartDate.Value, relBirthday.StartDate.Value, PeriodUnits.YearMonthDay, true); sb.AppendLine(string.Format(" {0} is {1} to {2}, who is {3} younger than {4}", member.CommonName, selfRelationshipTypeCode, relName, timeYounger, mName)); } else { string timeOlder = Analytics.GetTimeBetween(relBirthday.StartDate.Value, memberBirthday.StartDate.Value, PeriodUnits.YearMonthDay, true); sb.AppendLine(string.Format(" {0} is {1} to {2}, who is {3} older than {4}", member.CommonName, selfRelationshipTypeCode, relName, timeOlder, mName)); } if (rel.Details != null) { foreach (var relationshipDetail in rel.Details) { sb.AppendLine(string.Format(" {0}", relationshipDetail.DetailTypeText)); if (relationshipDetail.StartDate.HasValue) { sb.AppendLine(string.Format(" {0} : {1}", relationshipDetail.DetailTypeStartText, relationshipDetail.StartDate.ToString())); } if (relationshipDetail.EndDate.HasValue) { sb.AppendLine(string.Format(" {0}", relationshipDetail.DetailTypeEndText, relationshipDetail.EndDate.ToString())); } sb.AppendLine(string.Format(" {0}", relationshipDetail.Story)); } } } } } sb.AppendLine(string.Format("\nFun Facts!")); MemberViewModel mike = group.GetMember("Mike"); CombinedRelationshipReadModel rSpouse = mike.GetRelationship(RelationshipTypeEnum.Wife); DetailViewModel wedding = rSpouse.GetDetail(DetailTypeEnum.Wedding); MemberViewModel lisa = group.GetMember("Lisa"); DetailViewModel lBirthday = lisa.GetDetail(DetailTypeEnum.LifeSpan); string howLong = Analytics.GetTimeBetween(wedding.StartDate.Value, lBirthday.StartDate.Value, PeriodUnits.YearMonthDay, true); sb.AppendLine(string.Format(" Lisa was born {0} after her parents were married", howLong)); MemberViewModel sara = group.GetMember("Sara"); DetailViewModel sBirthday = sara.GetDetail(DetailTypeEnum.LifeSpan); howLong = Analytics.GetTimeBetween(wedding.StartDate.Value, sBirthday.StartDate.Value, PeriodUnits.YearMonthDay, true); sb.AppendLine(string.Format(" Sara was born {0} after her parents were married", howLong)); howLong = Analytics.GetTimeBetween(lBirthday.StartDate.Value, sBirthday.StartDate.Value, PeriodUnits.YearMonthDay, true); sb.AppendLine(string.Format(" Sara was born {0} after Lisa was born", howLong)); return(sb.ToString()); }
public static DetailViewModel GetBirthday(this MemberViewModel member) { return(member?.GetDetail(DetailTypeEnum.LifeSpan)); }