/// <summary> /// Adds the attendance record. /// </summary> /// <param name="kioskLocationAttendance">The kiosk location attendance.</param> /// <param name="attendance">The attendance.</param> private static void AddAttendanceRecord(KioskLocationAttendance kioskLocationAttendance, AttendanceInfo attendance) { if (attendance.GroupId == null && attendance.Schedule == null) { // Shouldn't happen, but just in case... return; } if (attendance.PersonId == null) { // Shouldn't happen, but just in case... return; } 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.GroupName; groupAttendance.Schedules = new List <KioskScheduleAttendance>(); kioskLocationAttendance.Groups.Add(groupAttendance); } var scheduleAttendance = groupAttendance.Schedules.Where(s => s.ScheduleId == attendance.Schedule.Id).FirstOrDefault(); if (scheduleAttendance == null) { scheduleAttendance = new KioskScheduleAttendance(); scheduleAttendance.ScheduleId = attendance.Schedule.Id; scheduleAttendance.ScheduleName = attendance.Schedule.Name; scheduleAttendance.IsActive = Attendance.CalculateIsCurrentlyCheckedIn(attendance.StartDateTime, attendance.EndDateTime, attendance.CampusId, attendance.Schedule); scheduleAttendance.PersonIds = new List <int>(); groupAttendance.Schedules.Add(scheduleAttendance); } if (!scheduleAttendance.PersonIds.Contains(attendance.PersonId.Value)) { scheduleAttendance.PersonIds.Add(attendance.PersonId.Value); } }