Ejemplo n.º 1
0
 public IHttpActionResult GetMySpouse(int contactid)
 {
     return(Authorized(token =>
     {
         try
         {
             var family = _contactRelationshipService.GetMyImmediateFamilyRelationships(contactid, token);
             var spouse = family.Where(f => f.Relationship_Id == 1).Select(s => new FamilyMember
             {
                 Age = s.Age,
                 ContactId = s.Contact_Id,
                 Email = s.Email_Address,
                 LastName = s.Last_Name,
                 PreferredName = s.Preferred_Name,
                 RelationshipId = s.Relationship_Id,
                 ParticipantId = s.Participant_Id,
                 HighSchoolGraduationYear = s.HighSchoolGraduationYear
             }).SingleOrDefault();
             return Ok(spouse);
         }
         catch (Exception ex)
         {
             var apiError = new ApiErrorDto("Get Spouse Failed", ex);
             throw new HttpResponseException(apiError.HttpResponseMessage);
         }
     }));
 }
Ejemplo n.º 2
0
        public List <FamilyMember> GetImmediateFamilyParticipants(string token)
        {
            var relationships = new List <FamilyMember>();
            var contactId     = _authenticationService.GetContactId(token);
            var me            = _participantService.GetParticipant(contactId);
            var myParticipant = new FamilyMember
            {
                ContactId     = contactId,
                Email         = me.EmailAddress,
                LoggedInUser  = true,
                ParticipantId = me.ParticipantId,
                PreferredName = me.PreferredName,
                Age           = me.Age
            };

            relationships.Add(myParticipant);

            // get family for contact Id
            var contactRelationships =
                _contactRelationshipService.GetMyImmediateFamilyRelationships(contactId, token).ToList();
            var family = contactRelationships.Select(contact => new FamilyMember
            {
                ContactId                = contact.Contact_Id,
                Email                    = contact.Email_Address,
                LastName                 = contact.Last_Name,
                LoggedInUser             = false,
                ParticipantId            = contact.Participant_Id,
                PreferredName            = contact.Preferred_Name,
                RelationshipId           = contact.Relationship_Id,
                Age                      = contact.Age,
                HighSchoolGraduationYear = contact.HighSchoolGraduationYear
            }).ToList();

            relationships.AddRange(family);

            return(relationships.OrderByDescending(s => s.Age).ToList());
        }