Beispiel #1
0
        /// <summary>
        /// Determines if Attendance the meets roster status filter.
        /// </summary>
        /// <param name="attendance">The attendance.</param>
        /// <param name="rosterStatusFilter">The roster status filter.</param>
        /// <returns></returns>
        public static bool AttendanceMeetsRosterStatusFilter(RosterAttendeeAttendance attendance, RosterStatusFilter rosterStatusFilter)
        {
            RosterAttendeeStatus rosterAttendeeStatus = GetRosterAttendeeStatus(attendance.EndDateTime, attendance.PresentDateTime);

            return(AppliesToRosterStatusFilter(rosterAttendeeStatus, rosterStatusFilter));
        }
Beispiel #2
0
        /// <summary>
        /// Sets the attendance-specific properties.
        /// </summary>
        /// <param name="attendance">The attendance.</param>
        /// <param name="checkinAreaPathsLookup">The checkin area paths lookup.</param>
        private void SetAttendanceInfo(RosterAttendeeAttendance attendance, Dictionary <int, CheckinAreaPath> checkinAreaPathsLookup)
        {
            // Keep track of each Attendance ID tied to this Attendee so we can manage them all as a group.
            this.Attendances.Add(attendance, true);

            // Tag(s).
            string tag = attendance.AttendanceCode;

            if (tag.IsNotNullOrWhiteSpace() && !this.UniqueTags.Contains(tag, StringComparer.OrdinalIgnoreCase))
            {
                this.UniqueTags.Add(tag);
            }

            // Service Time(s).
            string serviceTime = attendance.Schedule?.Name;

            if (serviceTime.IsNotNullOrWhiteSpace() && !this.UniqueServiceTimes.Contains(serviceTime, StringComparer.OrdinalIgnoreCase))
            {
                this.UniqueServiceTimes.Add(serviceTime);
            }

            // Status: if this Attendee has multiple Attendances, the most recent attendaces
            var latestAttendance = this.Attendances
                                   .OrderByDescending(a => a.StartDateTime)
                                   .First();

            this.Statuses = this.Attendances.Select(s => GetRosterAttendeeStatus(s.EndDateTime, s.PresentDateTime)).ToArray();

            // If this Attendee has multiple Attendances, use the DateTime from the most recent
            this.CheckInTime     = latestAttendance.StartDateTime;
            this.PresentDateTime = latestAttendance.PresentDateTime;
            this.CheckOutTime    = latestAttendance.EndDateTime;

            this.GroupTypeId = latestAttendance.GroupTypeId;

            this.GroupName = latestAttendance.GroupName;

            // GroupId should have a value, but just in case, we'll do some null safety.
            this.GroupId = latestAttendance.GroupId ?? 0;

            if (GroupTypeId.HasValue)
            {
                this.GroupTypePath = checkinAreaPathsLookup.GetValueOrNull(GroupTypeId.Value)?.Path;
            }

            this.ParentGroupId          = latestAttendance.ParentGroupId;
            this.ParentGroupName        = latestAttendance.ParentGroupName;
            this.ParentGroupGroupTypeId = latestAttendance.ParentGroupGroupTypeId;
            if (this.ParentGroupGroupTypeId.HasValue)
            {
                this.ParentGroupGroupTypePath = checkinAreaPathsLookup.GetValueOrNull(ParentGroupGroupTypeId.Value)?.Path;
            }

            this.IsFirstTime = latestAttendance?.IsFirstTime ?? false;

            // ScheduleId should have a value, but just in case, we'll do some null safety.
            this.ScheduleId = latestAttendance.ScheduleId ?? 0;

            this._parentsNames = latestAttendance.ParentsNames;

            this.ScheduleIds = this.Attendances.Select(a => a.ScheduleId ?? 0).Distinct().ToArray();

            this.RoomName = NamedLocationCache.Get(latestAttendance.LocationId ?? 0)?.Name;
        }