public TakeAttendanceModel Build(Data.Entities.Section section, DateTime date) { var target = new TakeAttendanceModel(); target.SectionId = section.SectionIdentity; target.Section = section.UniqueSectionCode + " (" + section.LocalCourseCode + ", " + section.ClassPeriodName + ")"; target.SessionId = section.Session.SessionIdentity; target.Session = section.Session.SessionName; target.Date = date.ToShortDateString(); var studentSectionAssociationsOnDate = section.StudentSectionAssociations .Where(ssa => new DateRange(ssa.BeginDate, ssa.EndDate.GetValueOrDefault()).Includes(date)).ToList(); target.StudentRows = studentSectionAssociationsOnDate.Select(ssa => ssa.Student) .Select(s => new StudentAttendanceRowModel { StudentUsi = s.StudentUSI, StudentName = s.FirstName + " " + s.LastSurname, ProfileThumbnailUrl = _profilePhotoUrlFetcher.GetProfilePhotoThumbnailUrlOrDefault(s.StudentUSI), AttendanceType = AttendanceEventCategoryDescriptorEnum.InAttendance }).ToList(); var existingStudentSectionAttendanceEvents = section.StudentSectionAttendanceEvents.Where(ssae => ssae.EventDate == date).ToList(); if (!existingStudentSectionAttendanceEvents.IsNullOrEmpty()) { foreach (var ssae in existingStudentSectionAttendanceEvents) { target.StudentRows.First(sr => sr.StudentUsi == ssae.StudentUSI).AttendanceType = (AttendanceEventCategoryDescriptorEnum) ssae.AttendanceEventCategoryDescriptorId; } } return target; }
public TakeAttendanceModel Build(Data.Entities.Section section, DateTime date) { var target = new TakeAttendanceModel(); target.SectionId = section.SectionIdentity; target.Section = section.UniqueSectionCode + " (" + section.LocalCourseCode + ", " + section.ClassPeriodName + ")"; target.SessionId = section.Session.SessionIdentity; target.Session = section.Session.SessionName; target.Date = date.ToShortDateString(); var studentSectionAssociationsOnDate = section.StudentSectionAssociations .Where(ssa => new DateRange(ssa.BeginDate, ssa.EndDate.GetValueOrDefault()).Includes(date)).ToList(); target.StudentRows = studentSectionAssociationsOnDate.Select(ssa => ssa.Student) .Select(s => new StudentAttendanceRowModel { StudentUsi = s.StudentUSI, StudentName = s.FirstName + " " + s.LastSurname, ProfileThumbnailUrl = _profilePhotoUrlFetcher.GetProfilePhotoThumbnailUrlOrDefault(s.StudentUSI), AttendanceType = AttendanceEventCategoryDescriptorEnum.InAttendance }).ToList(); var existingStudentSectionAttendanceEvents = section.StudentSectionAttendanceEvents.Where(ssae => ssae.EventDate == date).ToList(); if (!existingStudentSectionAttendanceEvents.IsNullOrEmpty()) { foreach (var ssae in existingStudentSectionAttendanceEvents) { target.StudentRows.First(sr => sr.StudentUsi == ssae.StudentUSI).AttendanceType = (AttendanceEventCategoryDescriptorEnum)ssae.AttendanceEventCategoryDescriptorId; } } return(target); }
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 IEnumerable <Data.Entities.StudentSectionAttendanceEvent> Build(TakeAttendanceModel takeAttendanceModel, Data.Entities.Section section) { return(takeAttendanceModel.StudentRows.Select(sr => new Data.Entities.StudentSectionAttendanceEvent { StudentUSI = sr.StudentUsi, Student = section.StudentSectionAssociations.First(ssa => ssa.StudentUSI == sr.StudentUsi).Student, AttendanceEventCategoryDescriptorId = (int)sr.AttendanceType, EventDate = DateTime.Parse(takeAttendanceModel.Date), SchoolId = section.SchoolId, ClassPeriodName = section.ClassPeriodName, ClassroomIdentificationCode = section.ClassroomIdentificationCode, LocalCourseCode = section.LocalCourseCode, TermTypeId = section.TermTypeId, SchoolYear = section.SchoolYear })); }
public IEnumerable<Data.Entities.StudentSectionAttendanceEvent> Build(TakeAttendanceModel takeAttendanceModel, Data.Entities.Section section) { return takeAttendanceModel.StudentRows.Select(sr => new Data.Entities.StudentSectionAttendanceEvent { StudentUSI = sr.StudentUsi, Student = section.StudentSectionAssociations.First(ssa => ssa.StudentUSI == sr.StudentUsi).Student, AttendanceEventCategoryDescriptorId = (int) sr.AttendanceType, EventDate = DateTime.Parse(takeAttendanceModel.Date), SchoolId = section.SchoolId, ClassPeriodName = section.ClassPeriodName, ClassroomIdentificationCode = section.ClassroomIdentificationCode, LocalCourseCode = section.LocalCourseCode, TermTypeId = section.TermTypeId, SchoolYear = section.SchoolYear }); }
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()); }