public virtual ActionResult GetStudents(TakeAttendanceModel takeAttendanceModel)
        {
            if (!ModelState.IsValid)
            {
                return(View(MVC.Attendance.Views.Take, takeAttendanceModel));
            }

            var date    = DateTime.Parse(takeAttendanceModel.Date);
            var section = _sectionRepository.GetWithStudentAttendance(takeAttendanceModel.SectionId.GetValueOrDefault());
            var takeAttendanceModelWithStudents = _sectionToTakeAttendanceModelMapper.Build(section, date);

            return(View(MVC.Attendance.Views.Take, takeAttendanceModelWithStudents));
        }
        public TakeAttendanceModel Build()
        {
            var takeAttendanceModel = new TakeAttendanceModel
            {
                Date      = _date,
                SectionId = _sectionId,
                Section   = Section,
                SessionId = _sessionId,
                Session   = Session,
            };

            if (_studentRows.Any())
            {
                takeAttendanceModel.StudentRows = _studentRows;
            }

            return(takeAttendanceModel);
        }
        public virtual ActionResult Save(TakeAttendanceModel takeAttendanceModel)
        {
            if (!ModelState.IsValid)
            {
                return(View(MVC.Attendance.Views.Take, takeAttendanceModel));
            }

            var section = _sectionRepository.GetWithAttendanceFlags(takeAttendanceModel.SectionId);

            _genericRepository.Get <Section>(s => s.SectionIdentity == takeAttendanceModel.SectionId, s => s.StudentSectionAssociations.Select(ssa => ssa.Student));

            var studentSectionAttendanceEventList = _takeAttendanceModelToStudentSectionAttendanceEventListMapper.Build(takeAttendanceModel, section);

            _attendanceService.RecordAttendanceFor(section, DateTime.Parse(takeAttendanceModel.Date), studentSectionAttendanceEventList);

            _genericRepository.Save();

            return(RedirectToAction("GetStudents", takeAttendanceModel.Clone()));
        }
 public virtual ActionResult Take()
 {
     return(View(TakeAttendanceModel.CreateNew()));
 }