Beispiel #1
0
            /// <summary>
            /// Initializes a new instance of the <see cref="AttendanceInfo" /> class
            /// Use this if adding an Attendance record
            /// </summary>
            /// <param name="attendance">The attendance.</param>
            /// <param name="locationId">The location identifier.</param>
            public AttendanceInfo(Attendance attendance, int locationId)
            {
                KioskLocationAttendance kioskLocationAttendance = KioskLocationAttendance.Get(locationId);
                var groupId = attendance.Occurrence?.GroupId;

                if (groupId == null)
                {
                    return;
                }

                // If we can get GroupName from kioskLocationAttendance.Groups, we can avoid lazy loading attendance.Occurrence.Group.
                var groupName = kioskLocationAttendance.Groups.Where(g => g.GroupId == groupId.Value).FirstOrDefault()?.GroupName;

                if (groupName == null)
                {
                    groupName = attendance.Occurrence?.Group?.Name;
                }

                EndDateTime   = attendance.EndDateTime;
                StartDateTime = attendance.StartDateTime;
                CampusId      = attendance.CampusId;
                GroupId       = groupId;
                GroupName     = groupName;
                Schedule      = attendance.Occurrence?.Schedule;
                PersonId      = attendance.PersonAlias?.PersonId;
            }