示例#1
0
        public IEnumerable <StudentAttendanceViewModel> GetByCourse(OfferedViewModel offered)
        {
            var records = new List <StudentAttendanceViewModel>();
            var block   = Context.attendance_block
                          .Where(w => w.BeginDate == offered.StartDate)
                          .FirstOrDefault();

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

                foreach (var student in StudentRepository.GetByOfferedId(offered.Id))
                {
                    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);
        }
        public ActionResult Course(string id)
        {
            if (string.IsNullOrEmpty(id))
            {
                return(View());
            }

            OfferedViewModel offered = uow.OfferedRepository.GetById(Convert.ToInt32(id));
            var attendanceRecords    = uow.GetByCourse(offered);

            return(View(attendanceRecords));
        }
示例#3
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);
        }