Esempio n. 1
0
 protected List <GroupMember> GetFilteredMembers()
 {
     if (CurrentGroupFilters.Any())
     {
         CurrentGroupMember.LoadAttributes();
         var filterAttribute = CurrentGroupFilters.FirstOrDefault();
         var filter          = CurrentGroupMember.GetAttributeValue(filterAttribute);
         return(GetFilteredMembers(filter));
     }
     else
     {
         return(CurrentGroup.Members.ToList());
     }
 }
Esempio n. 2
0
        public List <GroupMember> GetFilteredMembers(string filter)
        {
            List <GroupMember> members = new List <GroupMember>();

            if (CurrentGroupFilters.Any())
            {
                var filterAttribute = CurrentGroupFilters.FirstOrDefault();
                foreach (var member in CurrentGroup.Members)
                {
                    member.LoadAttributes();
                    if (member.GetAttributeValue(filterAttribute) == filter)
                    {
                        members.Add(member);
                    }
                }
            }
            return(members);
        }
Esempio n. 3
0
        private List <string> GetCurrentGroupFilterValues()
        {
            var filterValues = new List <string>();

            if (CurrentGroupFilters.Any())
            {
                var filterAttribute = CurrentGroupFilters.FirstOrDefault();
                foreach (var member in CurrentGroup.Members)
                {
                    member.LoadAttributes();
                    var filterValue = member.GetAttributeValue(filterAttribute);
                    if (filterAttribute != null && !filterValues.Contains(filterValue))
                    {
                        filterValues.Add(filterValue);
                    }
                }
            }
            return(filterValues);
        }
        private void BindDropDown()
        {
            RockContext rockContext = new RockContext();

            if (CurrentGroup.Schedule != null)
            {
                AttendanceService attendanceService = new AttendanceService(rockContext);
                var occurances = attendanceService.Queryable().Where(a => a.Occurrence.GroupId == CurrentGroup.Id)
                                 .DistinctBy(s => s.StartDateTime)
                                 .Select(s => s.StartDateTime)
                                 .Take(50)
                                 .ToList()
                                 .Select(s => new
                {
                    Id   = (s - new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalSeconds,
                    Name = s.ToString("MMM d, yyyy -  h:mmtt")
                })
                                 .ToList();

                if (CurrentGroup.Schedule.ScheduleType == ScheduleType.Named ||
                    CurrentGroup.Schedule.ScheduleType == ScheduleType.Custom)
                {
                    var prevSchedules = CurrentGroup.Schedule
                                        .GetScheduledStartTimes(Rock.RockDateTime.Today.AddYears(-1), Rock.RockDateTime.Today.AddDays(1))
                                        .OrderByDescending(o => o)
                                        .Take(10)
                                        .Select(s => new
                    {
                        Id   = (s - new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalSeconds,
                        Name = s.ToString("MMM d, yyyy -  h:mmtt")
                    })
                                        .Where(a => !occurances.Select(o => o.Id).Contains(a.Id))
                                        .ToList();
                    occurances.AddRange(prevSchedules);
                }
                else if (CurrentGroup.Schedule.ScheduleType == ScheduleType.Weekly)
                {
                    var schedules = new List <DateTime>();

                    DateTime lastSchedule = Rock.RockDateTime.Today;
                    //Crawl backward to find the last time this occured
                    while (lastSchedule.DayOfWeek != CurrentGroup.Schedule.WeeklyDayOfWeek)
                    {
                        lastSchedule = lastSchedule.AddDays(-1);
                    }
                    lastSchedule = lastSchedule.AddMinutes(CurrentGroup.Schedule.WeeklyTimeOfDay.Value.TotalMinutes);
                    schedules.Add(lastSchedule);
                    for (int i = 1; i < 10; i++)
                    {
                        schedules.Add(lastSchedule.AddDays(i * -7));
                    }
                    occurances.AddRange(schedules
                                        .Select(s => new
                    {
                        Id   = (s - new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalSeconds,
                        Name = s.ToString("MMM d, yyyy -  h:mmtt")
                    }
                                                )
                                        .Where(a => !occurances.Select(o => o.Id).Contains(a.Id))
                                        );
                }

                ddlOccurence.DataSource = occurances.OrderByDescending(o => o.Id);
                ddlOccurence.DataBind();

                //Drop down for filter values
                ddlFilter.Visible = (GetAttributeValue("ShowFilters").AsBoolean() && CurrentGroupFilters.Any());
                if (ddlFilter.Visible)
                {
                    ddlFilter.DataSource = CurrentGroupFilterValues
                                           .Select(s => new
                    {
                        Id   = s,
                        Name = s,
                    }
                                                   );
                    ddlFilter.DataBind();
                    CurrentGroupMember.LoadAttributes();
                    ddlFilter.SelectedValue = CurrentGroupMember.GetAttributeValue(CurrentGroupFilters.FirstOrDefault());
                }
            }
        }