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); }
private AssessmentSection Build(CreateModel source, Data.Entities.Section section) { var target = new AssessmentSection(); MapAssessment(target); MapSection(source, target, section); return(target); }
private void MapSection(CreateModel source, AssessmentSection target, Data.Entities.Section section) { target.SchoolId = section.SchoolId; target.SchoolYear = section.SchoolYear; target.TermTypeId = section.TermTypeId; target.LocalCourseCode = section.LocalCourseCode; target.ClassroomIdentificationCode = section.ClassroomIdentificationCode; target.ClassPeriodName = section.ClassPeriodName; }
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 })); }