Ejemplo n.º 1
0
        public static StudentClassAttendanceOldViewData Create(ClassAttendanceDetails attendance, StudentClassAttendance studentAttendance, AttendanceReason reason)
        {
            var res = new StudentClassAttendanceOldViewData
            {
                PersonId                = studentAttendance.StudentId,
                ClassId                 = attendance.Class.Id,
                ClassName               = attendance.Class.Name,
                Date                    = studentAttendance.Date,
                AttendanceReasonId      = studentAttendance.AttendanceReasonId,
                Student                 = StudentViewData.Create(studentAttendance.Student),
                Level                   = studentAttendance.Level,
                IsPosted                = attendance.IsPosted,
                AbsentPreviousDay       = studentAttendance.AbsentPreviousDay,
                ReadOnly                = studentAttendance.ReadOnly,
                ReadOnlyReason          = studentAttendance.ReadOnlyReason,
                FullClassReadOnly       = attendance.ReadOnly,
                FullClassReadOnlyReason = attendance.ReadOnlyReason,
                IsDailyAttendancePeriod = attendance.IsDailyAttendancePeriod
            };

            if (reason != null)
            {
                res.AttendanceReason = AttendanceReasonViewData.Create(reason);
            }
            return(res);
        }
Ejemplo n.º 2
0
        public ClassAttendanceDetails GetClassAttendance(DateTime date, int classId)
        {
            var mp = ServiceLocator.MarkingPeriodService.GetLastClassMarkingPeriod(classId, date);

            if (mp == null)
            {
                //throw new ChalkableException("No marking period is scheduled on this date");
                return(null);
            }

            var sa = ConnectorLocator.AttendanceConnector.GetSectionAttendance(date, classId);

            if (sa != null)
            {
                var clazz   = ServiceLocator.ClassService.GetClassDetailsById(classId);
                var persons = ServiceLocator.StudentService.GetClassStudents(classId, mp.Id);

                var res = new ClassAttendanceDetails
                {
                    Class = clazz,
                    Date  = date,
                    IsDailyAttendancePeriod = sa.IsDailyAttendancePeriod,
                    ClassId            = sa.SectionId,
                    IsPosted           = sa.IsPosted,
                    MergeRosters       = sa.MergeRosters,
                    ReadOnly           = sa.ReadOnly,
                    ReadOnlyReason     = sa.ReadOnlyReason,
                    StudentAttendances = new List <StudentClassAttendance>()
                };

                foreach (var ssa in sa.StudentAttendance)
                {
                    var student = persons.FirstOrDefault(x => x.Id == ssa.StudentId);
                    if (student != null)
                    {
                        res.StudentAttendances.Add(new StudentClassAttendance
                        {
                            ClassId            = ssa.SectionId,
                            AttendanceReasonId = ssa.ReasonId,
                            Date              = date,
                            StudentId         = ssa.StudentId,
                            Level             = ClassroomLevelToLevelCvt(ssa.ClassroomLevel),
                            Student           = student,
                            Category          = ssa.Category,
                            AbsentPreviousDay = ssa.AbsentPreviousDay,
                            ReadOnly          = ssa.ReadOnly,
                            ReadOnlyReason    = ssa.ReadOnlyReason,
                        });
                    }
                }
                return(res);
            }
            return(null);
        }
Ejemplo n.º 3
0
        public static ClassAttendanceViewData Create(ClassAttendanceDetails classAttendance, IList <AttendanceReason> attendanceReasons)
        {
            var res = new ClassAttendanceViewData
            {
                ClassId                 = classAttendance.Class.Id,
                ClassName               = classAttendance.Class.Name,
                Date                    = classAttendance.Date,
                IsPosted                = classAttendance.IsPosted,
                ReadOnly                = classAttendance.ReadOnly,
                ReadOnlyReason          = classAttendance.ReadOnlyReason,
                IsDailyAttendancePeriod = classAttendance.IsDailyAttendancePeriod,
                StudentAttendances      = StudentClassAttendanceViewData.Create(classAttendance.StudentAttendances, attendanceReasons)
            };

            return(res);
        }
Ejemplo n.º 4
0
        public static IList <StudentClassAttendanceOldViewData> Create(ClassAttendanceDetails attendance, IList <AttendanceReason> attendanceReasons = null)
        {
            var res = new List <StudentClassAttendanceOldViewData>();

            if (attendance != null && attendance.StudentAttendances.Count > 0)
            {
                foreach (var studentAtt in attendance.StudentAttendances)
                {
                    AttendanceReason reason = null;
                    if (attendanceReasons != null && attendanceReasons.Count > 0 && studentAtt.AttendanceReasonId.HasValue)
                    {
                        reason = attendanceReasons.FirstOrDefault(x => x.Id == studentAtt.AttendanceReasonId);
                    }
                    res.Add(Create(attendance, studentAtt, reason));
                }
            }
            return(res);
        }