Example #1
0
        private List <MpGroupParticipant> LoadGroupParticipants(int groupId, string token, bool activeGroups = true)
        {
            var groupParticipants = new List <MpGroupParticipant>();

            logger.Debug("Getting participants for group " + groupId);
            List <Dictionary <string, object> > participants;

            if (activeGroups)
            {
                participants = ministryPlatformService.GetSubpageViewRecords(GroupsParticipantsSubPageId, groupId, token);
            }
            else
            {
                participants = ministryPlatformService.GetSubpageViewRecords(CurrentGroupsParticipantsSubPage, groupId, token);
            }

            if (participants != null && participants.Count > 0)
            {
                foreach (Dictionary <string, object> p in participants)
                {
                    object pid = null;
                    p.TryGetValue("Participant_ID", out pid);
                    if (pid != null)
                    {
                        var parti = new MpGroupParticipant
                        {
                            ContactId     = p.ToInt("Contact_ID"),
                            ParticipantId = p.ToInt("Participant_ID"),
                            IsApprovedSmallGroupLeader = p.ToBool("Approved_Small_Group_Leader"),
                            GroupParticipantId         = p.ToInt("dp_RecordID"),
                            GroupRoleId    = p.ToInt("Group_Role_ID"),
                            GroupRoleTitle = p.ToString("Role_Title"),
                            LastName       = p.ToString("Last_Name"),
                            NickName       = p.ToString("Nickname"),
                            Email          = p.ToString("Email")
                        };

                        if (p.ContainsKey("Start_Date"))
                        {
                            parti.StartDate = p.ToNullableDate("Start_Date");
                        }
                        groupParticipants.Add(parti);
                    }
                }
            }
            else
            {
                logger.Debug("No participants found for group id " + groupId);
            }
            return(groupParticipants);
        }
Example #2
0
 private bool RespondedOnWeekend(Models.Crossroads.Events.Event evnt, MpGroupParticipant gm)
 {
     // this person did not respond, they are a potential contact so far
     // now determine if this event is a weekend event...
     if (evnt.StartDate.IsWeekend())
     {
         // first look for other responses on the same day...
         if (!SearchForResponsesByParticipantAndDate(gm.ParticipantId, evnt.StartDate.ToMinistryPlatformSearchFormat()))
         {
             return(SearchForResponsesByParticipantAndDate(gm.ParticipantId, evnt.StartDate.DayOfWeek == DayOfWeek.Saturday ? evnt.StartDate.AddDays(1).ToMinistryPlatformSearchFormat() : evnt.StartDate.AddDays(-1).ToMinistryPlatformSearchFormat()));
         }
         return(true);
     }
     return(false);
 }