Ejemplo n.º 1
0
        public IEnumerable <StudentAttendanceViewModel> GetByStudent(StudentViewModel student)
        {
            var records  = new List <StudentAttendanceViewModel>();
            var offereds = OfferedRepository.GetByStudentID(student.StudentId);

            if (offereds != null)
            {
                foreach (var offered in offereds)
                {
                    attendance_block block = Context.attendance_block
                                             .Where(w => w.BeginDate == offered.StartDate)
                                             .FirstOrDefault();

                    if (block == null)
                    {
                        continue;
                    }

                    var sessions = block.attendance_session
                                   .Where(w => w.TimeslotId == "AM")
                                   .ToList().Select(s => new SessionViewModel(s)).ToList();

                    var studentAttendanceViewModel = new StudentAttendanceViewModel();
                    studentAttendanceViewModel.Student           = student;
                    studentAttendanceViewModel.CourseOffered     = offered;
                    studentAttendanceViewModel.Sessions          = sessions;
                    studentAttendanceViewModel.AttendanceRecords = GetAttendanceRecords(student.Barcode, block.BeginDate, block.EndDate);
                    records.Add(studentAttendanceViewModel);
                }
            }

            return(records);
        }
Ejemplo n.º 2
0
        public StudentAttendanceViewModel GetByStudentCourse(StudentViewModel student, OfferedViewModel offered)
        {
            var record = new StudentAttendanceViewModel();

            attendance_block block = Context.attendance_block
                                     .Where(w => w.BeginDate == offered.StartDate)
                                     .FirstOrDefault();

            if (block != null)
            {
                var sessions = block.attendance_session.Where(w => w.TimeslotId == "AM").ToList().Select(s => new SessionViewModel(s)).ToList();

                record.Student           = student;
                record.CourseOffered     = offered;
                record.Sessions          = sessions;
                record.AttendanceRecords = GetAttendanceRecords(student.Barcode, block.BeginDate, block.EndDate);
            }

            return(record);
        }