Rock.CheckIn.KioskLocationAttendance.AddAttendanceRecord C# (CSharp) Method

AddAttendanceRecord() private static method

Adds the attendance record.
private static AddAttendanceRecord ( KioskLocationAttendance kioskLocationAttendance, Attendance attendance ) : void
kioskLocationAttendance KioskLocationAttendance The kiosk location attendance.
attendance Attendance The attendance.
return void
        private static void AddAttendanceRecord( KioskLocationAttendance kioskLocationAttendance, Attendance attendance )
        {
            if ( attendance.GroupId.HasValue && attendance.ScheduleId.HasValue && attendance.PersonAlias != null )
            {
                var groupAttendance = kioskLocationAttendance.Groups.Where( g => g.GroupId == attendance.GroupId ).FirstOrDefault();
                if ( groupAttendance == null )
                {
                    groupAttendance = new KioskGroupAttendance();
                    groupAttendance.GroupId = attendance.GroupId.Value;
                    groupAttendance.GroupName = attendance.Group.Name;
                    groupAttendance.Schedules = new List<KioskScheduleAttendance>();
                    kioskLocationAttendance.Groups.Add( groupAttendance );
                }

                var scheduleAttendance = groupAttendance.Schedules.Where( s => s.ScheduleId == attendance.ScheduleId ).FirstOrDefault();
                if ( scheduleAttendance == null )
                {
                    scheduleAttendance = new KioskScheduleAttendance();
                    scheduleAttendance.ScheduleId = attendance.ScheduleId.Value;
                    scheduleAttendance.ScheduleName = attendance.Schedule.Name;
                    scheduleAttendance.IsActive = attendance.Schedule.IsScheduleOrCheckInActive;
                    scheduleAttendance.PersonIds = new List<int>();
                    groupAttendance.Schedules.Add( scheduleAttendance );
                }

                if ( !scheduleAttendance.PersonIds.Contains( attendance.PersonAlias.PersonId ) )
                {
                    scheduleAttendance.PersonIds.Add( attendance.PersonAlias.PersonId );
                }
            }
        }