예제 #1
0
        /// <summary>
        /// Executes the specified workflow.
        /// </summary>
        /// <param name="action">The workflow action.</param>
        /// <param name="entity">The entity.</param>
        /// <param name="errorMessages">The error messages.</param>
        /// <returns></returns>
        /// <exception cref="System.NotImplementedException"></exception>
        public override bool Execute(Model.WorkflowAction action, Object entity, out List <string> errorMessages)
        {
            var checkInState = GetCheckInState(entity, out errorMessages);

            if (checkInState != null)
            {
                foreach (var family in checkInState.CheckIn.Families.ToList())
                {
                    foreach (var person in family.People.ToList())
                    {
                        foreach (var groupType in person.GroupTypes.ToList())
                        {
                            foreach (var group in groupType.Groups.ToList())
                            {
                                foreach (var location in group.Locations.ToList())
                                {
                                    if (location.Schedules.Count == 0)
                                    {
                                        group.Locations.Remove(location);
                                    }
                                }
                            }
                        }
                    }
                }

                return(true);
            }

            return(false);
        }
        /// <summary>
        /// Executes the specified workflow.
        /// </summary>
        /// <param name="rockContext">The rock context.</param>
        /// <param name="action">The workflow action.</param>
        /// <param name="entity">The entity.</param>
        /// <param name="errorMessages">The error messages.</param>
        /// <returns></returns>
        /// <exception cref="System.NotImplementedException"></exception>
        public override bool Execute(RockContext rockContext, Model.WorkflowAction action, Object entity, out List <string> errorMessages)
        {
            var checkInState = GetCheckInState(entity, out errorMessages);

            if (checkInState == null)
            {
                return(false);
            }
            var family = checkInState.CheckIn.CurrentFamily;

            if (family != null)
            {
                var remove = GetAttributeValue(action, "Remove").AsBoolean();

                if (checkInState.CheckInType.TypeOfCheckin == TypeOfCheckin.Family)
                {
                    var currentPerson = checkInState.CheckIn.CurrentPerson;
                    if (currentPerson != null)
                    {
                        FilterGroups(currentPerson, rockContext, remove);
                    }
                }
                else
                {
                    foreach (var person in family.People)
                    {
                        FilterGroups(person, rockContext, remove);
                    }
                }
            }

            return(true);
        }
예제 #3
0
        /// <summary>
        /// Executes the specified workflow.
        /// </summary>
        /// <param name="rockContext">The rock context.</param>
        /// <param name="action">The workflow action.</param>
        /// <param name="entity">The entity.</param>
        /// <param name="errorMessages">The error messages.</param>
        /// <returns></returns>
        /// <exception cref="System.NotImplementedException"></exception>
        public override bool Execute(RockContext rockContext, Model.WorkflowAction action, Object entity, out List <string> errorMessages)
        {
            List <int> roles = GetRoles(rockContext);

            var checkInState = GetCheckInState(entity, out errorMessages);

            if (checkInState != null)
            {
                if (!roles.Any())
                {
                    return(true);
                }

                var family = checkInState.CheckIn.CurrentFamily;
                if (family != null)
                {
                    return(ProcessForFamily(rockContext, family, checkInState.CheckInType != null && checkInState.CheckInType.PreventInactivePeople));
                }
                else
                {
                    errorMessages.Add("There is not a family that is selected");
                }

                return(false);
            }

            return(false);
        }
        /// <summary>
        /// Executes the specified workflow.
        /// </summary>
        /// <param name="rockContext">The rock context.</param>
        /// <param name="action">The workflow action.</param>
        /// <param name="entity">The entity.</param>
        /// <param name="errorMessages">The error messages.</param>
        /// <returns></returns>
        /// <exception cref="System.NotImplementedException"></exception>
        public override bool Execute(RockContext rockContext, Model.WorkflowAction action, Object entity, out List <string> errorMessages)
        {
            var checkInState = GetCheckInState(entity, out errorMessages);

            if (checkInState == null)
            {
                return(false);
            }

            bool removeSNGroups    = bool.Parse(GetAttributeValue(action, "RemoveSpecialNeedsGroups") ?? "true");
            bool removeNonSNGroups = bool.Parse(GetAttributeValue(action, "RemoveNonSpecialNeedsGroups") ?? "false");

            var family = checkInState.CheckIn.Families.FirstOrDefault(f => f.Selected);

            if (family != null)
            {
                var remove = GetAttributeValue(action, "Remove").AsBoolean();

                foreach (var person in family.People)
                {
                    bool isSNPerson = bool.Parse(person.Person.GetAttributeValue("IsSpecialNeeds") ?? "false");
                    foreach (var groupType in person.GroupTypes.ToList())
                    {
                        foreach (var group in groupType.Groups.ToList())
                        {
                            bool isSNGroup = bool.Parse(group.Group.GetAttributeValue("IsSpecialNeeds") ?? "false");

                            // If the group is special needs but the person is not, then remove it.
                            if (removeSNGroups && isSNGroup && !(isSNPerson))
                            {
                                if (remove)
                                {
                                    groupType.Groups.Remove(group);
                                }
                                else
                                {
                                    group.ExcludedByFilter = true;
                                }
                                continue;
                            }

                            // or if the setting is enabled and the person is SN but the group is not.
                            if (removeNonSNGroups && isSNPerson && !isSNGroup)
                            {
                                if (remove)
                                {
                                    groupType.Groups.Remove(group);
                                }
                                else
                                {
                                    group.ExcludedByFilter = true;
                                }
                            }
                        }
                    }
                }
            }

            return(true);
        }
예제 #5
0
        /// <summary>
        /// Executes the specified workflow.
        /// </summary>
        /// <param name="rockContext">The rock context.</param>
        /// <param name="action">The workflow action.</param>
        /// <param name="entity">The entity.</param>
        /// <param name="errorMessages">The error messages.</param>
        /// <returns></returns>
        /// <exception cref="System.NotImplementedException"></exception>
        public override bool Execute(RockContext rockContext, Model.WorkflowAction action, Object entity, out List <string> errorMessages)
        {
            var checkInState = GetCheckInState(entity, out errorMessages);

            if (checkInState != null)
            {
                var family = checkInState.CheckIn.Families.Where(f => f.Selected).FirstOrDefault();
                if (family != null)
                {
                    var service = new GroupMemberService(rockContext);
                    foreach (var groupMember in service.GetByGroupId(family.Group.Id).AsNoTracking().ToList())
                    {
                        if (!family.People.Any(p => p.Person.Id == groupMember.PersonId))
                        {
                            var person = new CheckInPerson();
                            person.Person       = groupMember.Person.Clone(false);
                            person.FamilyMember = true;
                            family.People.Add(person);
                        }
                    }

                    return(true);
                }
                else
                {
                    errorMessages.Add("There is not a family that is selected");
                }

                return(false);
            }

            return(false);
        }
예제 #6
0
        /// <summary>
        /// Executes the specified workflow.
        /// </summary>
        /// <param name="rockContext">The rock context.</param>
        /// <param name="action">The workflow action.</param>
        /// <param name="entity">The entity.</param>
        /// <param name="errorMessages">The error messages.</param>
        /// <returns></returns>
        /// <exception cref="System.NotImplementedException"></exception>
        public override bool Execute(RockContext rockContext, Model.WorkflowAction action, Object entity, out List <string> errorMessages)
        {
            var checkInState = GetCheckInState(entity, out errorMessages);

            if (checkInState != null)
            {
                bool loadAll = GetAttributeValue(action, "LoadAll").AsBoolean();

                foreach (var family in checkInState.CheckIn.GetFamilies(true))
                {
                    foreach (var person in family.GetPeople(!loadAll))
                    {
                        var memberGroupIds = new GroupMemberService(rockContext)
                                             .Queryable()
                                             .AsNoTracking()
                                             .Where(m => m.GroupMemberStatus == GroupMemberStatus.Active && m.PersonId == person.Person.Id)
                                             .Select(m => m.GroupId)
                                             .ToList();

                        foreach (var groupType in person.GetGroupTypes(!loadAll))
                        {
                            var kioskGroupType = checkInState.Kiosk.ActiveGroupTypes(checkInState.ConfiguredGroupTypes)
                                                 .Where(g => g.GroupType.Id == groupType.GroupType.Id)
                                                 .FirstOrDefault();

                            if (kioskGroupType != null)
                            {
                                foreach (var kioskGroup in kioskGroupType.KioskGroups.Where(g => g.IsCheckInActive))
                                {
                                    bool validGroup = true;

                                    var configuredKioskGroup = checkInState.ConfiguredGroups;
                                    if (configuredKioskGroup.Any())
                                    {
                                        validGroup = configuredKioskGroup.Contains(kioskGroup.Group.Id);
                                    }

                                    if (validGroup && groupType.GroupType.AttendanceRule == AttendanceRule.AlreadyBelongs)
                                    {
                                        validGroup = memberGroupIds.Contains(kioskGroup.Group.Id);
                                    }

                                    if (validGroup && !groupType.Groups.Any(g => g.Group.Id == kioskGroup.Group.Id))
                                    {
                                        var checkInGroup = new CheckInGroup();
                                        checkInGroup.Group = kioskGroup.Group.Clone(false);
                                        checkInGroup.Group.CopyAttributesFrom(kioskGroup.Group);
                                        groupType.Groups.Add(checkInGroup);
                                    }
                                }
                            }
                        }
                    }
                }

                return(true);
            }

            return(false);
        }
예제 #7
0
        /// <summary>
        /// Executes the specified workflow.
        /// </summary>
        /// <param name="rockContext">The rock context.</param>
        /// <param name="action">The workflow action.</param>
        /// <param name="entity">The entity.</param>
        /// <param name="errorMessages">The error messages.</param>
        /// <returns></returns>
        /// <exception cref="System.NotImplementedException"></exception>
        public override bool Execute(RockContext rockContext, Model.WorkflowAction action, Object entity, out List <string> errorMessages)
        {
            var checkInState = GetCheckInState(entity, out errorMessages);

            if (checkInState != null)
            {
                foreach (var family in checkInState.CheckIn.Families.ToList())
                {
                    foreach (var person in family.People.ToList())
                    {
                        foreach (var groupType in person.GroupTypes.ToList())
                        {
                            foreach (var group in groupType.Groups.ToList())
                            {
                                if (group.Locations.Count == 0)
                                {
                                    groupType.Groups.Remove(group);
                                }
                                else if (!group.Locations.Any(l => !l.ExcludedByFilter))
                                {
                                    group.ExcludedByFilter = true;
                                }
                            }
                        }
                    }
                }

                return(true);
            }

            return(false);
        }
예제 #8
0
        /// <summary>
        /// Executes the specified workflow.
        /// </summary>
        /// <param name="rockContext">The rock context.</param>
        /// <param name="action">The workflow action.</param>
        /// <param name="entity">The entity.</param>
        /// <param name="errorMessages">The error messages.</param>
        /// <returns></returns>
        /// <exception cref="System.NotImplementedException"></exception>
        public override bool Execute(RockContext rockContext, Model.WorkflowAction action, Object entity, out List <string> errorMessages)
        {
            var checkInState = GetCheckInState(entity, out errorMessages);

            if (checkInState != null)
            {
                foreach (var family in checkInState.CheckIn.Families.ToList())
                {
                    // Make a copy of the original set of people because we may need them
                    // if they are checking-out (not checking-in).
                    family.OriginalPeople = new List <Rock.CheckIn.CheckInPerson>(family.People);

                    foreach (var person in family.People.ToList())
                    {
                        if (person.GroupTypes.Count == 0)
                        {
                            family.People.Remove(person);
                        }
                        else if (person.GroupTypes.All(t => t.ExcludedByFilter))
                        {
                            person.ExcludedByFilter = true;
                        }
                    }
                }

                return(true);
            }

            return(false);
        }
예제 #9
0
        /// <summary>
        /// Executes the specified workflow.
        /// </summary>
        /// <param name="action">The workflow action.</param>
        /// <param name="entity">The entity.</param>
        /// <param name="errorMessages">The error messages.</param>
        /// <returns></returns>
        /// <exception cref="System.NotImplementedException"></exception>
        public override bool Execute(Model.WorkflowAction action, Object entity, out List <string> errorMessages)
        {
            var checkInState = GetCheckInState(entity, out errorMessages);

            if (checkInState != null)
            {
                var family = checkInState.CheckIn.Families.Where(f => f.Selected).FirstOrDefault();
                if (family != null)
                {
                    foreach (var person in family.People.Where(p => p.Selected))
                    {
                        string personsGender = person.Person.Gender.ToString("d");

                        foreach (var groupType in person.GroupTypes.ToList())
                        {
                            foreach (var group in groupType.Groups.ToList())
                            {
                                var groupAttributes = group.Group.GetAttributeValues("Gender");
                                if (groupAttributes.Any() && !groupAttributes.Contains(personsGender))
                                {
                                    groupType.Groups.Remove(group);
                                }
                            }
                        }
                    }
                }

                return(true);
            }

            return(false);
        }
예제 #10
0
        /// <summary>
        /// Executes the specified workflow.
        /// </summary>
        /// <param name="action">The workflow action.</param>
        /// <param name="entity">The entity.</param>
        /// <param name="errorMessages">The error messages.</param>
        /// <returns></returns>
        /// <exception cref="System.NotImplementedException"></exception>
        public override bool Execute(Model.WorkflowAction action, Object entity, out List <string> errorMessages)
        {
            var checkInState = GetCheckInState(entity, out errorMessages);

            if (checkInState != null)
            {
                var family = checkInState.CheckIn.Families.Where(f => f.Selected).FirstOrDefault();
                if (family != null)
                {
                    foreach (var person in family.People.Where(p => p.Selected))
                    {
                        foreach (var groupType in person.GroupTypes.Where(g => g.Selected))
                        {
                            foreach (var group in groupType.Groups)
                            {
                                foreach (var location in group.Locations.ToList())
                                {
                                    if (!location.Location.IsActive)
                                    {
                                        group.Locations.Remove(location);
                                    }
                                }
                            }
                        }
                    }
                }

                return(true);
            }

            return(false);
        }
예제 #11
0
        /// <summary>
        /// Executes the specified workflow.
        /// </summary>
        /// <param name="rockContext">The rock context.</param>
        /// <param name="action">The workflow action.</param>
        /// <param name="entity">The entity.</param>
        /// <param name="errorMessages">The error messages.</param>
        /// <returns></returns>
        /// <exception cref="System.NotImplementedException"></exception>
        public override bool Execute(RockContext rockContext, Model.WorkflowAction action, Object entity, out List <string> errorMessages)
        {
            var checkInState = GetCheckInState(entity, out errorMessages);

            if (checkInState != null)
            {
                foreach (var family in checkInState.CheckIn.GetFamilies(true))
                {
                    foreach (var person in family.People)
                    {
                        foreach (var kioskGroupType in checkInState.Kiosk.ActiveGroupTypes(checkInState.ConfiguredGroupTypes))
                        {
                            if (kioskGroupType.KioskGroups.SelectMany(g => g.KioskLocations).Any(l => l.IsCheckInActive && l.IsActiveAndNotFull))
                            {
                                if (!person.GroupTypes.Any(g => g.GroupType.Id == kioskGroupType.GroupType.Id))
                                {
                                    var checkinGroupType = new CheckInGroupType();
                                    checkinGroupType.GroupType = kioskGroupType.GroupType;
                                    person.GroupTypes.Add(checkinGroupType);
                                }
                            }
                        }
                    }
                }

                return(true);
            }

            return(false);
        }
예제 #12
0
        /// <summary>
        /// Executes the specified workflow.
        /// </summary>
        /// <param name="action">The workflow action.</param>
        /// <param name="entity">The entity.</param>
        /// <param name="errorMessages">The error messages.</param>
        /// <returns></returns>
        /// <exception cref="System.NotImplementedException"></exception>
        public override bool Execute(Model.WorkflowAction action, Object entity, out List <string> errorMessages)
        {
            var checkInState = GetCheckInState(entity, out errorMessages);

            if (checkInState != null)
            {
                foreach (var family in checkInState.CheckIn.Families.Where(f => f.Selected).ToList())
                {
                    foreach (var person in family.People)
                    {
                        foreach (var kioskGroupType in checkInState.Kiosk.FilteredGroupTypes(checkInState.ConfiguredGroupTypes))
                        {
                            if (kioskGroupType.KioskGroups.SelectMany(g => g.KioskLocations).Any(l => l.Location.IsActive))
                            {
                                if (!person.GroupTypes.Any(g => g.GroupType.Id == kioskGroupType.GroupType.Id))
                                {
                                    var checkinGroupType = new CheckInGroupType();
                                    checkinGroupType.GroupType = kioskGroupType.GroupType.Clone(false);
                                    checkinGroupType.GroupType.CopyAttributesFrom(kioskGroupType.GroupType);
                                    person.GroupTypes.Add(checkinGroupType);
                                }
                            }
                        }
                    }
                }

                return(true);
            }

            return(false);
        }
예제 #13
0
        /// <summary>
        /// Executes the specified workflow.
        /// </summary>
        /// <param name="action">The workflow action.</param>
        /// <param name="entity">The entity.</param>
        /// <param name="errorMessages">The error messages.</param>
        /// <returns></returns>
        /// <exception cref="System.NotImplementedException"></exception>
        public override bool Execute(Model.WorkflowAction action, Object entity, out List <string> errorMessages)
        {
            var checkInState = GetCheckInState(entity, out errorMessages);

            if (checkInState != null)
            {
                var family = checkInState.CheckIn.Families.Where(f => f.Selected).FirstOrDefault();
                if (family != null)
                {
                    foreach (var person in family.People)
                    {
                        double?age = person.Person.AgePrecise;

                        foreach (var groupType in person.GroupTypes.ToList())
                        {
                            string   ageRange     = groupType.GroupType.GetAttributeValue("AgeRange") ?? string.Empty;
                            string[] ageRangePair = ageRange.Split(new char[] { ',' }, StringSplitOptions.None);
                            string   minAgeValue  = null;
                            string   maxAgeValue  = null;
                            if (ageRangePair.Length == 2)
                            {
                                minAgeValue = ageRangePair[0];
                                maxAgeValue = ageRangePair[1];
                            }

                            if (minAgeValue != null)
                            {
                                double minAge = 0;
                                if (double.TryParse(minAgeValue, out minAge))
                                {
                                    if (!age.HasValue || age < minAge)
                                    {
                                        person.GroupTypes.Remove(groupType);
                                        continue;
                                    }
                                }
                            }

                            if (maxAgeValue != null)
                            {
                                double maxAge = 0;
                                if (double.TryParse(maxAgeValue, out maxAge))
                                {
                                    if (!age.HasValue || age > maxAge)
                                    {
                                        person.GroupTypes.Remove(groupType);
                                        continue;
                                    }
                                }
                            }
                        }
                    }
                }

                return(true);
            }

            return(false);
        }
예제 #14
0
        /// <summary>
        /// Executes the specified workflow.
        /// </summary>
        /// <param name="rockContext">The rock context.</param>
        /// <param name="action">The workflow action.</param>
        /// <param name="entity">The entity.</param>
        /// <param name="errorMessages">The error messages.</param>
        /// <returns></returns>
        public override bool Execute(RockContext rockContext, Model.WorkflowAction action, object entity, out List <string> errorMessages)
        {
            var checkInState = GetCheckInState(entity, out errorMessages);

            if (checkInState == null)
            {
                return(false);
            }

            bool loadSelectedOnly = GetAttributeValue(action, AttributeKey.LoadAll).AsBoolean() == false;
            var  today            = RockDateTime.Today;

            var kioskGroupTypeLookup = checkInState.Kiosk.ActiveGroupTypes(checkInState.ConfiguredGroupTypes).ToDictionary(k => k.GroupType.Id, v => v);

            var remove = GetAttributeValue(action, AttributeKey.Remove).AsBoolean();

            foreach (var family in checkInState.CheckIn.GetFamilies(true))
            {
                // see if there are any groups for the people in this family that have a AttendanceRecordRequiredForCheckIn requirement that needs to be checked
                int[] groupIdsWithScheduledRequirements = family.People
                                                          .SelectMany(a => a.GroupTypes)
                                                          .SelectMany(a => a.Groups.Where(g => g.Group.AttendanceRecordRequiredForCheckIn != AttendanceRecordRequiredForCheckIn.ScheduleNotRequired))
                                                          .Select(a => a.Group.Id).ToArray();

                List <PersonAttendanceScheduled> attendanceScheduledLookup = null;

                if (groupIdsWithScheduledRequirements.Any())
                {
                    var personIds = family.People.Select(p => p.Person.Id).ToList();

                    // get attendance records where the person was scheduled (doesn't matter if they confirmed or declined)
                    var attendanceScheduledQuery = new AttendanceService(rockContext).Queryable()
                                                   .Where(a =>
                                                          (a.ScheduledToAttend == true || a.RequestedToAttend == true) &&
                                                          personIds.Contains(a.PersonAlias.PersonId) &&
                                                          a.Occurrence.OccurrenceDate == today.Date &&
                                                          a.Occurrence.GroupId.HasValue &&
                                                          a.Occurrence.LocationId.HasValue &&
                                                          a.Occurrence.ScheduleId.HasValue &&
                                                          groupIdsWithScheduledRequirements.Contains(a.Occurrence.GroupId.Value));

                    attendanceScheduledLookup = attendanceScheduledQuery.Select(a => new PersonAttendanceScheduled
                    {
                        PersonId   = a.PersonAlias.PersonId,
                        GroupId    = a.Occurrence.GroupId.Value,
                        LocationId = a.Occurrence.LocationId.Value,
                        ScheduleId = a.Occurrence.ScheduleId.Value
                    }).ToList();
                }

                foreach (var person in family.GetPeople(loadSelectedOnly))
                {
                    LoadPersonSchedules(person, attendanceScheduledLookup, kioskGroupTypeLookup, loadSelectedOnly, remove, checkInState);
                }
            }

            return(true);
        }
예제 #15
0
        /// <summary>
        /// Executes the specified workflow.
        /// </summary>
        /// <param name="rockContext">The rock context.</param>
        /// <param name="action">The workflow action.</param>
        /// <param name="entity">The entity.</param>
        /// <param name="errorMessages">The error messages.</param>
        /// <returns></returns>
        /// <exception cref="System.NotImplementedException"></exception>
        public override bool Execute(RockContext rockContext, Model.WorkflowAction action, Object entity, out List <string> errorMessages)
        {
            var checkInState = GetCheckInState(entity, out errorMessages);

            if (checkInState != null)
            {
                bool loadAll = false;
                if (bool.TryParse(GetAttributeValue(action, "LoadAll"), out loadAll) && loadAll)
                {
                    loadAll = true;
                }

                foreach (var family in checkInState.CheckIn.Families.Where(f => f.Selected).ToList())
                {
                    foreach (var person in family.People.Where(p => p.Selected).ToList())
                    {
                        foreach (var groupType in person.GroupTypes.Where(g => g.Selected || loadAll).ToList())
                        {
                            var kioskGroupType = checkInState.Kiosk.FilteredGroupTypes(checkInState.ConfiguredGroupTypes).Where(g => g.GroupType.Id == groupType.GroupType.Id).FirstOrDefault();
                            if (kioskGroupType != null)
                            {
                                foreach (var group in groupType.Groups.Where(g => g.Selected || loadAll).ToList())
                                {
                                    foreach (var location in group.Locations.Where(l => l.Selected || loadAll).ToList())
                                    {
                                        var kioskGroup = kioskGroupType.KioskGroups.Where(g => g.Group.Id == group.Group.Id).FirstOrDefault();
                                        if (kioskGroup != null)
                                        {
                                            var kioskLocation = kioskGroup.KioskLocations.Where(l => l.Location.Id == location.Location.Id).FirstOrDefault();
                                            if (kioskLocation != null)
                                            {
                                                foreach (var kioskSchedule in kioskLocation.KioskSchedules)
                                                {
                                                    if (!location.Schedules.Any(s => s.Schedule.Id == kioskSchedule.Schedule.Id))
                                                    {
                                                        var checkInSchedule = new CheckInSchedule();
                                                        checkInSchedule.Schedule  = kioskSchedule.Schedule.Clone(false);
                                                        checkInSchedule.StartTime = kioskSchedule.StartTime;
                                                        location.Schedules.Add(checkInSchedule);
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                return(true);
            }

            return(false);
        }
예제 #16
0
        /// <summary>
        /// Executes the specified workflow.
        /// </summary>
        /// <param name="rockContext">The rock context.</param>
        /// <param name="action">The workflow action.</param>
        /// <param name="entity">The entity.</param>
        /// <param name="errorMessages">The error messages.</param>
        /// <returns></returns>
        /// <exception cref="System.NotImplementedException"></exception>
        public override bool Execute( RockContext rockContext, Model.WorkflowAction action, Object entity, out List<string> errorMessages )
        {
            var checkInState = GetCheckInState( entity, out errorMessages );
            if ( checkInState != null )
            {
                ProcessForFamily( rockContext, checkInState.CheckIn.CurrentFamily );
                return true;
            }

            return false;
        }
예제 #17
0
        /// <summary>
        /// Executes the specified workflow.
        /// </summary>
        /// <param name="rockContext">The rock context.</param>
        /// <param name="action">The workflow action.</param>
        /// <param name="entity">The entity.</param>
        /// <param name="errorMessages">The error messages.</param>
        /// <returns></returns>
        /// <exception cref="System.NotImplementedException"></exception>
        public override bool Execute(RockContext rockContext, Model.WorkflowAction action, Object entity, out List <string> errorMessages)
        {
            var checkInState = GetCheckInState(entity, out errorMessages);

            if (checkInState != null && checkInState.CheckInType.TypeOfCheckin == TypeOfCheckin.Family)
            {
                bool configPrevents = checkInState.CheckInType.PreventDuplicateCheckin;
                var  family         = checkInState.CheckIn.CurrentFamily;
                return(FilterByPreviousCheckin.ProcessForFamily(rockContext, family, configPrevents));
            }

            return(false);
        }
예제 #18
0
        /// <summary>
        /// Executes the specified workflow.
        /// </summary>
        /// <param name="rockContext">The rock context.</param>
        /// <param name="action">The workflow action.</param>
        /// <param name="entity">The entity.</param>
        /// <param name="errorMessages">The error messages.</param>
        /// <returns></returns>
        /// <exception cref="System.NotImplementedException"></exception>
        public override bool Execute(RockContext rockContext, Model.WorkflowAction action, Object entity, out List <string> errorMessages)
        {
            var checkInState = GetCheckInState(entity, out errorMessages);

            if (checkInState == null)
            {
                return(false);
            }

            var family = checkInState.CheckIn.Families.FirstOrDefault(f => f.Selected);

            if (family != null)
            {
                var remove = GetAttributeValue(action, "Remove").AsBoolean();

                foreach (var person in family.People)
                {
                    if (person.Person.Attributes == null)
                    {
                        person.Person.LoadAttributes(rockContext);
                    }

                    string personAbilityLevel = person.Person.GetAttributeValue("AbilityLevel").ToUpper();
                    if (string.IsNullOrWhiteSpace(personAbilityLevel))
                    {
                        continue;
                    }

                    foreach (var groupType in person.GroupTypes.ToList())
                    {
                        foreach (var group in groupType.Groups.ToList())
                        {
                            var groupAttributes = group.Group.GetAttributeValues("AbilityLevel");
                            if (groupAttributes.Any() && !groupAttributes.Contains(personAbilityLevel, StringComparer.OrdinalIgnoreCase))
                            {
                                if (remove)
                                {
                                    groupType.Groups.Remove(group);
                                }
                                else
                                {
                                    group.ExcludedByFilter = true;
                                }
                            }
                        }
                    }
                }
            }

            return(true);
        }
예제 #19
0
        /// <summary>
        /// Executes the specified workflow.
        /// </summary>
        /// <param name="action">The workflow action.</param>
        /// <param name="entity">The entity.</param>
        /// <param name="errorMessages">The error messages.</param>
        /// <returns></returns>
        /// <exception cref="System.NotImplementedException"></exception>
        public override bool Execute(Model.WorkflowAction action, Object entity, out List <string> errorMessages)
        {
            var checkInState = GetCheckInState(entity, out errorMessages);

            if (checkInState != null)
            {
                using (new Rock.Data.UnitOfWorkScope())
                {
                    var personService          = new PersonService();
                    var memberService          = new GroupMemberService();
                    IQueryable <Person> people = null;

                    if (checkInState.CheckIn.SearchType.Guid.Equals(new Guid(SystemGuid.DefinedValue.CHECKIN_SEARCH_TYPE_PHONE_NUMBER)))
                    {
                        people = personService.GetByPhonePartial(checkInState.CheckIn.SearchValue);
                    }
                    else if (checkInState.CheckIn.SearchType.Guid.Equals(new Guid(SystemGuid.DefinedValue.CHECKIN_SEARCH_TYPE_NAME)))
                    {
                        people = personService.GetByFullName(checkInState.CheckIn.SearchValue);
                    }
                    else
                    {
                        errorMessages.Add("Invalid Search Type");
                        return(false);
                    }

                    foreach (var person in people.ToList())
                    {
                        foreach (var group in person.Members.Where(m => m.Group.GroupType.Guid == new Guid(SystemGuid.GroupType.GROUPTYPE_FAMILY)).Select(m => m.Group).ToList())
                        {
                            var family = checkInState.CheckIn.Families.Where(f => f.Group.Id == group.Id).FirstOrDefault();
                            if (family == null)
                            {
                                family       = new CheckInFamily();
                                family.Group = group.Clone(false);
                                family.Group.LoadAttributes();
                                family.Caption    = group.ToString();
                                family.SubCaption = memberService.GetFirstNames(group.Id).ToList().AsDelimited(", ");
                                checkInState.CheckIn.Families.Add(family);
                            }
                        }
                    }

                    return(true);
                }
            }

            errorMessages.Add("Invalid Check-in State");
            return(false);
        }
예제 #20
0
        /// <summary>
        /// Executes the specified workflow.
        /// </summary>
        /// <param name="rockContext">The rock context.</param>
        /// <param name="action">The workflow action.</param>
        /// <param name="entity">The entity.</param>
        /// <param name="errorMessages">The error messages.</param>
        /// <returns></returns>
        /// <exception cref="System.NotImplementedException"></exception>
        public override bool Execute(RockContext rockContext, Model.WorkflowAction action, Object entity, out List <string> errorMessages)
        {
            var checkInState = GetCheckInState(entity, out errorMessages);

            if (checkInState != null)
            {
                bool loadAll = GetAttributeValue(action, "LoadAll").AsBoolean();

                foreach (var family in checkInState.CheckIn.GetFamilies(true))
                {
                    foreach (var person in family.GetPeople(!loadAll))
                    {
                        foreach (var groupType in person.GetGroupTypes(!loadAll).ToList())
                        {
                            var kioskGroupType = checkInState.Kiosk.ActiveGroupTypes(checkInState.ConfiguredGroupTypes)
                                                 .Where(g => g.GroupType.Id == groupType.GroupType.Id)
                                                 .FirstOrDefault();

                            if (kioskGroupType != null)
                            {
                                foreach (var group in groupType.GetGroups(!loadAll))
                                {
                                    foreach (var kioskGroup in kioskGroupType.KioskGroups
                                             .Where(g => g.Group.Id == group.Group.Id && g.IsCheckInActive)
                                             .ToList())
                                    {
                                        foreach (var kioskLocation in kioskGroup.KioskLocations.Where(l => l.IsCheckInActive && l.IsActiveAndNotFull))
                                        {
                                            if (!group.Locations.Any(l => l.Location.Id == kioskLocation.Location.Id))
                                            {
                                                var checkInLocation = new CheckInLocation();
                                                checkInLocation.Location = kioskLocation.Location.Clone(false);
                                                checkInLocation.Location.CopyAttributesFrom(kioskLocation.Location);
                                                checkInLocation.CampusId = kioskLocation.CampusId;
                                                checkInLocation.Order    = kioskLocation.Order;
                                                group.Locations.Add(checkInLocation);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                return(true);
            }

            return(false);
        }
예제 #21
0
        /// <summary>
        /// Executes the specified workflow.
        /// </summary>
        /// <param name="rockContext">The rock context.</param>
        /// <param name="action">The workflow action.</param>
        /// <param name="entity">The entity.</param>
        /// <param name="errorMessages">The error messages.</param>
        /// <returns></returns>
        /// <exception cref="System.NotImplementedException"></exception>
        public override bool Execute(RockContext rockContext, Model.WorkflowAction action, Object entity, out List <string> errorMessages)
        {
            var checkInState = GetCheckInState(entity, out errorMessages);

            if (checkInState != null)
            {
                bool loadAll = false;
                if (bool.TryParse(GetAttributeValue(action, "LoadAll"), out loadAll) && loadAll)
                {
                    loadAll = true;
                }

                foreach (var family in checkInState.CheckIn.Families.Where(f => f.Selected).ToList())
                {
                    foreach (var person in family.People.Where(p => p.Selected || loadAll).ToList())
                    {
                        foreach (var groupType in person.GroupTypes.Where(g => g.Selected || loadAll).ToList())
                        {
                            var kioskGroupType = checkInState.Kiosk.FilteredGroupTypes(checkInState.ConfiguredGroupTypes).Where(g => g.GroupType.Id == groupType.GroupType.Id).FirstOrDefault();
                            if (kioskGroupType != null)
                            {
                                foreach (var kioskGroup in kioskGroupType.KioskGroups)
                                {
                                    bool validGroup = true;
                                    if (groupType.GroupType.AttendanceRule == AttendanceRule.AlreadyBelongs)
                                    {
                                        validGroup = new GroupMemberService(rockContext).Queryable()
                                                     .Any(m =>
                                                          m.GroupId == kioskGroup.Group.Id &&
                                                          m.PersonId == person.Person.Id);
                                    }

                                    if (validGroup && !groupType.Groups.Any(g => g.Group.Id == kioskGroup.Group.Id))
                                    {
                                        var checkInGroup = new CheckInGroup();
                                        checkInGroup.Group = kioskGroup.Group.Clone(false);
                                        checkInGroup.Group.CopyAttributesFrom(kioskGroup.Group);
                                        groupType.Groups.Add(checkInGroup);
                                    }
                                }
                            }
                        }
                    }
                }

                return(true);
            }

            return(false);
        }
예제 #22
0
        /// <summary>
        /// Executes the specified workflow.
        /// </summary>
        /// <param name="rockContext">The rock context.</param>
        /// <param name="action">The workflow action.</param>
        /// <param name="entity">The entity.</param>
        /// <param name="errorMessages">The error messages.</param>
        /// <returns></returns>
        /// <exception cref="System.NotImplementedException"></exception>
        public override bool Execute(RockContext rockContext, Model.WorkflowAction action, Object entity, out List <string> errorMessages)
        {
            var checkInState = GetCheckInState(entity, out errorMessages);

            if (checkInState != null)
            {
                var family = checkInState.CheckIn.CurrentFamily;
                if (family != null)
                {
                    var remove = GetAttributeValue(action, "Remove").AsBoolean();

                    foreach (var person in family.People)
                    {
                        foreach (var groupType in person.GroupTypes)
                        {
                            foreach (var group in groupType.Groups)
                            {
                                foreach (var location in group.Locations)
                                {
                                    location.AvailableForSchedule =
                                        location.Schedules
                                        .Where(s => !s.ExcludedByFilter)
                                        .Select(s => s.Schedule.Id)
                                        .ToList();
                                }

                                group.AvailableForSchedule =
                                    group.Locations
                                    .Where(l => !l.ExcludedByFilter)
                                    .SelectMany(l => l.AvailableForSchedule)
                                    .Distinct()
                                    .ToList();
                            }

                            groupType.AvailableForSchedule =
                                groupType.Groups
                                .Where(l => !l.ExcludedByFilter)
                                .SelectMany(l => l.AvailableForSchedule)
                                .Distinct()
                                .ToList();
                        }
                    }
                }

                return(true);
            }

            return(false);
        }
예제 #23
0
        /// <summary>
        /// Executes the specified workflow.
        /// </summary>
        /// <param name="rockContext">The rock context.</param>
        /// <param name="action">The workflow action.</param>
        /// <param name="entity">The entity.</param>
        /// <param name="errorMessages">The error messages.</param>
        /// <returns></returns>
        /// <exception cref="System.NotImplementedException"></exception>
        public override bool Execute(RockContext rockContext, Model.WorkflowAction action, Object entity, out List <string> errorMessages)
        {
            var checkInState = GetCheckInState(entity, out errorMessages);

            if (checkInState == null)
            {
                return(false);
            }

            var family = checkInState.CheckIn.Families.FirstOrDefault(f => f.Selected);

            if (family != null)
            {
                var remove = GetAttributeValue(action, "Remove").AsBoolean();

                foreach (var person in family.People.Where(p => p.Person.LastName.Length > 0))
                {
                    char lastInitial = char.Parse(person.Person.LastName.Substring(0, 1).ToUpper());
                    foreach (var groupType in person.GroupTypes.ToList())
                    {
                        foreach (var group in groupType.Groups.ToList())
                        {
                            string lastNameBeginLetterRange = group.Group.GetAttributeValue("LastNameBeginLetterRange");
                            string lastNameEndLetterRange   = group.Group.GetAttributeValue("LastNameEndLetterRange");

                            char rangeStart = (string.IsNullOrWhiteSpace(lastNameBeginLetterRange)) ? 'A' : char.Parse(lastNameBeginLetterRange.Trim().ToUpper());
                            char rangeEnd   = (string.IsNullOrWhiteSpace(lastNameEndLetterRange)) ? 'Z' : char.Parse(lastNameEndLetterRange.Trim().ToUpper());

                            // If the last name is not in range, remove the group
                            if (!(lastInitial >= rangeStart && lastInitial <= rangeEnd))
                            {
                                if (remove)
                                {
                                    groupType.Groups.Remove(group);
                                }
                                else
                                {
                                    group.ExcludedByFilter = true;
                                }
                            }
                        }
                    }
                }
            }

            return(true);
        }
예제 #24
0
        /// <summary>
        /// Executes the specified workflow.
        /// </summary>
        /// <param name="rockContext">The rock context.</param>
        /// <param name="action">The workflow action.</param>
        /// <param name="entity">The entity.</param>
        /// <param name="errorMessages">The error messages.</param>
        /// <returns></returns>
        /// <exception cref="System.NotImplementedException"></exception>
        public override bool Execute(RockContext rockContext, Model.WorkflowAction action, Object entity, out List <string> errorMessages)
        {
            var checkInState = GetCheckInState(entity, out errorMessages);

            if (checkInState != null)
            {
                var family = checkInState.CheckIn.CurrentFamily;
                if (family != null)
                {
                    var remove = GetAttributeValue(action, "Remove").AsBoolean();

                    foreach (var person in family.People)
                    {
                        foreach (var groupType in person.GroupTypes)
                        {
                            foreach (var group in groupType.Groups)
                            {
                                foreach (var location in group.Locations.ToList())
                                {
                                    if (location.Location.SoftRoomThreshold.HasValue)
                                    {
                                        var locAttendance = KioskLocationAttendance.Get(location.Location.Id);
                                        if (locAttendance != null &&
                                            !locAttendance.DistinctPersonIds.Contains(person.Person.Id) &&
                                            location.Location.SoftRoomThreshold.Value <= locAttendance.CurrentCount)
                                        {
                                            if (remove)
                                            {
                                                group.Locations.Remove(location);
                                            }
                                            else
                                            {
                                                location.ExcludedByFilter = true;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                return(true);
            }

            return(false);
        }
예제 #25
0
        /// <summary>
        /// Executes the specified workflow.
        /// </summary>
        /// <param name="action">The workflow action.</param>
        /// <param name="entity">The entity.</param>
        /// <param name="errorMessages">The error messages.</param>
        /// <returns></returns>
        /// <exception cref="System.NotImplementedException"></exception>
        public override bool Execute(Model.WorkflowAction action, Object entity, out List <string> errorMessages)
        {
            var checkInState = GetCheckInState(entity, out errorMessages);

            if (checkInState != null)
            {
                var family = checkInState.CheckIn.Families.Where(f => f.Selected).FirstOrDefault();
                if (family != null)
                {
                    foreach (var person in family.People.Where(f => f.Selected))
                    {
                        if (person.LastCheckIn != null)
                        {
                            var groupType = person.GroupTypes.Where(g => g.LastCheckIn == person.LastCheckIn).FirstOrDefault();
                            if (groupType != null)
                            {
                                groupType.PreSelected = true;
                                groupType.Selected    = true;
                                var group = groupType.Groups.Where(g => g.LastCheckIn == person.LastCheckIn).FirstOrDefault();
                                if (group != null)
                                {
                                    group.PreSelected = true;
                                    group.Selected    = true;
                                    var location = group.Locations.Where(l => l.LastCheckIn == person.LastCheckIn).FirstOrDefault();
                                    if (location != null)
                                    {
                                        location.PreSelected = true;
                                        location.Selected    = true;
                                        var schedule = location.Schedules.Where(s => s.LastCheckIn == person.LastCheckIn).FirstOrDefault();
                                        if (schedule != null)
                                        {
                                            schedule.PreSelected = true;
                                            schedule.Selected    = true;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                return(true);
            }

            return(false);
        }
예제 #26
0
        /// <summary>
        /// Executes the specified workflow.
        /// </summary>
        /// <param name="rockContext">The rock context.</param>
        /// <param name="action">The workflow action.</param>
        /// <param name="entity">The entity.</param>
        /// <param name="errorMessages">The error messages.</param>
        /// <returns></returns>
        /// <exception cref="System.NotImplementedException"></exception>
        public override bool Execute(RockContext rockContext, Model.WorkflowAction action, Object entity, out List <string> errorMessages)
        {
            var checkInState = GetCheckInState(entity, out errorMessages);

            if (checkInState != null)
            {
                var family = checkInState.CheckIn.CurrentFamily;
                if (family != null)
                {
                    var service = new GroupMemberService(rockContext);

                    var people = service.GetByGroupId(family.Group.Id).AsNoTracking();
                    if (checkInState.CheckInType != null && checkInState.CheckInType.PreventInactivePeopele)
                    {
                        var dvInactive = DefinedValueCache.Read(Rock.SystemGuid.DefinedValue.PERSON_RECORD_STATUS_INACTIVE.AsGuid());
                        if (dvInactive != null)
                        {
                            people = people.Where(m => m.Person.RecordStatusValueId != dvInactive.Id);
                        }
                    }

                    foreach (var groupMember in people.ToList())
                    {
                        if (!family.People.Any(p => p.Person.Id == groupMember.PersonId))
                        {
                            var person = new CheckInPerson();
                            person.Person       = groupMember.Person.Clone(false);
                            person.FamilyMember = true;
                            family.People.Add(person);
                        }
                    }

                    return(true);
                }
                else
                {
                    errorMessages.Add("There is not a family that is selected");
                }

                return(false);
            }

            return(false);
        }
예제 #27
0
        /// <summary>
        /// Executes the specified workflow.
        /// </summary>
        /// <param name="rockContext">The rock context.</param>
        /// <param name="action">The workflow action.</param>
        /// <param name="entity">The entity.</param>
        /// <param name="errorMessages">The error messages.</param>
        /// <returns></returns>
        /// <exception cref="System.NotImplementedException"></exception>
        public override bool Execute(RockContext rockContext, Model.WorkflowAction action, Object entity, out List <string> errorMessages)
        {
            var checkInState = GetCheckInState(entity, out errorMessages);

            if (checkInState != null)
            {
                foreach (var family in checkInState.CheckIn.Families.ToList())
                {
                    var remove = GetAttributeValue(action, "Remove").AsBoolean();

                    foreach (var person in family.People.ToList())
                    {
                        foreach (var groupType in person.GroupTypes.ToList())
                        {
                            foreach (var group in groupType.Groups.ToList())
                            {
                                foreach (var location in group.Locations.ToList())
                                {
                                    foreach (var schedule in location.Schedules.ToList())
                                    {
                                        if (!person.PossibleSchedules.Any(s => s.Schedule.Id == schedule.Schedule.Id && s.Selected))
                                        {
                                            if (remove)
                                            {
                                                location.Schedules.Remove(schedule);
                                            }
                                            else
                                            {
                                                schedule.ExcludedByFilter = true;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                return(true);
            }

            return(false);
        }
예제 #28
0
        /// <summary>
        /// Executes the specified workflow.
        /// </summary>
        /// <param name="rockContext">The rock context.</param>
        /// <param name="action">The workflow action.</param>
        /// <param name="entity">The entity.</param>
        /// <param name="errorMessages">The error messages.</param>
        /// <returns></returns>
        /// <exception cref="System.NotImplementedException"></exception>
        public override bool Execute(RockContext rockContext, Model.WorkflowAction action, Object entity, out List <string> errorMessages)
        {
            var checkInState = GetCheckInState(entity, out errorMessages);

            if (checkInState != null)
            {
                var family = checkInState.CheckIn.CurrentFamily;
                if (family != null)
                {
                    var remove = GetAttributeValue(action, "Remove").AsBoolean();

                    foreach (var person in family.People)
                    {
                        foreach (var groupType in person.GroupTypes)
                        {
                            foreach (var group in groupType.Groups)
                            {
                                foreach (var location in group.Locations.ToList())
                                {
                                    if (!location.IsActiveAndNotFull)
                                    {
                                        if (remove)
                                        {
                                            group.Locations.Remove(location);
                                        }
                                        else
                                        {
                                            location.ExcludedByFilter = true;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                return(true);
            }

            return(false);
        }
예제 #29
0
        /// <summary>
        /// Executes the specified workflow.
        /// </summary>
        /// <param name="action">The workflow action.</param>
        /// <param name="entity">The entity.</param>
        /// <param name="errorMessages">The error messages.</param>
        /// <returns></returns>
        /// <exception cref="System.NotImplementedException"></exception>
        public override bool Execute(Model.WorkflowAction action, Object entity, out List <string> errorMessages)
        {
            var checkInState = GetCheckInState(entity, out errorMessages);

            if (checkInState != null)
            {
                bool loadAll = false;
                if (bool.TryParse(GetAttributeValue(action, "LoadAll"), out loadAll) && loadAll)
                {
                    loadAll = true;
                }

                foreach (var family in checkInState.CheckIn.Families.Where(f => f.Selected).ToList())
                {
                    foreach (var person in family.People.Where(p => p.Selected || loadAll).ToList())
                    {
                        foreach (var groupType in person.GroupTypes.Where(g => g.Selected || loadAll).ToList())
                        {
                            var kioskGroupType = checkInState.Kiosk.FilteredGroupTypes(checkInState.ConfiguredGroupTypes).Where(g => g.GroupType.Id == groupType.GroupType.Id).FirstOrDefault();
                            if (kioskGroupType != null)
                            {
                                foreach (var kioskGroup in kioskGroupType.KioskGroups)
                                {
                                    if (!groupType.Groups.Any(g => g.Group.Id == kioskGroup.Group.Id))
                                    {
                                        var checkInGroup = new CheckInGroup();
                                        checkInGroup.Group = kioskGroup.Group.Clone(false);
                                        checkInGroup.Group.CopyAttributesFrom(kioskGroup.Group);
                                        groupType.Groups.Add(checkInGroup);
                                    }
                                }
                            }
                        }
                    }
                }

                return(true);
            }

            return(false);
        }
예제 #30
0
        /// <summary>
        /// Executes the specified workflow.
        /// </summary>
        /// <param name="rockContext">The rock context.</param>
        /// <param name="action">The workflow action.</param>
        /// <param name="entity">The entity.</param>
        /// <param name="errorMessages">The error messages.</param>
        /// <returns></returns>
        /// <exception cref="System.NotImplementedException"></exception>
        public override bool Execute(RockContext rockContext, Model.WorkflowAction action, Object entity, out List <string> errorMessages)
        {
            var checkInState = GetCheckInState(entity, out errorMessages);

            if (checkInState != null && checkInState.CheckInType.TypeOfCheckin == Rock.CheckIn.TypeOfCheckin.Family)
            {
                DateTime preSelectCutoff = RockDateTime.Today.AddDays(0 - checkInState.CheckInType.AutoSelectDaysBack);

                foreach (var family in checkInState.CheckIn.Families.Where(f => f.Selected))
                {
                    foreach (var person in family.People)
                    {
                        foreach (var groupType in person.GroupTypes)
                        {
                            groupType.PreSelected = groupType.LastCheckIn.HasValue && groupType.LastCheckIn.Value.CompareTo(preSelectCutoff) >= 0;

                            foreach (var group in groupType.Groups)
                            {
                                group.PreSelected = group.LastCheckIn.HasValue && group.LastCheckIn.Value.CompareTo(preSelectCutoff) >= 0;

                                foreach (var location in group.Locations)
                                {
                                    location.PreSelected = location.LastCheckIn.HasValue && location.LastCheckIn.Value.CompareTo(preSelectCutoff) >= 0;

                                    foreach (var schedule in location.Schedules)
                                    {
                                        schedule.PreSelected = schedule.LastCheckIn.HasValue && schedule.LastCheckIn.Value.CompareTo(preSelectCutoff) >= 0;
                                    }
                                }
                            }
                        }

                        person.PreSelected = person.GroupTypes.Any(t => t.PreSelected);
                    }
                }
            }

            return(true);
        }