Ejemplo n.º 1
0
        public List <FamilyMemberTripDto> GetFamilyMembers(int pledgeId, string token)
        {
            var family = _serveService.GetImmediateFamilyParticipants(token);
            var fam    = new List <FamilyMemberTripDto>();

            foreach (var f in family)
            {
                // get status of family member on trip
                var signedUpDate = _formSubmissionService.GetTripFormResponseByContactId(f.ContactId, pledgeId);
                var fm           = new FamilyMemberTripDto()
                {
                    Age            = f.Age,
                    ContactId      = f.ContactId,
                    Email          = f.Email,
                    LastName       = f.LastName,
                    LoggedInUser   = f.LoggedInUser,
                    ParticipantId  = f.ParticipantId,
                    PreferredName  = f.PreferredName,
                    RelationshipId = f.RelationshipId,
                    SignedUpDate   = signedUpDate,
                    SignedUp       = (signedUpDate != null)
                };
                fam.Add(fm);
            }
            return(fam);
        }
Ejemplo n.º 2
0
 public IHttpActionResult GetProfile(int contactId)
 {
     return(Authorized(token =>
     {
         try
         {
             // does the logged in user have permission to view this contact?
             //TODO: Move this security logic to MP, if for some reason we absulutly can't then centerlize all security logic that exists in the gateway
             var family = _serveService.GetImmediateFamilyParticipants(token);
             Person person = null;
             if (family.Where(f => f.ContactId == contactId).ToList().Count > 0)
             {
                 person = _personService.GetPerson(contactId);
             }
             if (person == null)
             {
                 return Unauthorized();
             }
             return Ok(person);
         }
         catch (Exception e)
         {
             var apiError = new ApiErrorDto("Get Profile Failed", e);
             throw new HttpResponseException(apiError.HttpResponseMessage);
         }
     }));
 }
Ejemplo n.º 3
0
        public List <FamilyMember> MyChildren(string token)
        {
            var family     = _serveService.GetImmediateFamilyParticipants(token);
            var myChildren = new List <FamilyMember>();

            foreach (var member in family)
            {
                var schoolGrade          = SchoolGrade(member.HighSchoolGraduationYear);
                var maxAgeWithoutGrade   = _configurationWrapper.GetConfigIntValue("MaxAgeWithoutGrade");
                var maxGradeForChildcare = _configurationWrapper.GetConfigIntValue("MaxGradeForChildcare");
                if (member.Age == 0)
                {
                    continue;
                }
                if (schoolGrade == 0 && member.Age <= maxAgeWithoutGrade)
                {
                    myChildren.Add(member);
                }
                else if (schoolGrade > 0 && schoolGrade <= maxGradeForChildcare)
                {
                    myChildren.Add(member);
                }
            }
            return(myChildren);
        }
Ejemplo n.º 4
0
        public List <FamilyMember> FamilyThatUserCanSubmitFor(string token)
        {
            var list   = _serveService.GetImmediateFamilyParticipants(token);
            var family =
                list.Where(
                    s =>
                    (s.RelationshipId == 0) || (s.RelationshipId == 29) ||
                    (s.RelationshipId == 21 && s.Age >= 10 && s.Age <= 13) ||
                    (s.RelationshipId == 6 && s.Age >= 10 && s.Age <= 13)).ToList();

            //TODO: I don't like these rules hard coded here, Relationship IDs and age limits
            return(family);
        }
Ejemplo n.º 5
0
 public IHttpActionResult GetFamily(int contactId = 0)
 {
     //TODO: I don't think you need to pass in contactId here, use the token
     return(Authorized(token =>
     {
         try
         {
             var list = _serveService.GetImmediateFamilyParticipants(token);
             return Ok(list);
         }
         catch (Exception ex)
         {
             var apiError = new ApiErrorDto("GetFamily Failed", ex);
             throw new HttpResponseException(apiError.HttpResponseMessage);
         }
     }));
 }