public DisciplineView(ScheduleRepository repo, Discipline discipline) { DisciplineId = discipline.DisciplineId; Name = discipline.Name; Attestation = Constants.Constants.Attestation.ContainsKey(discipline.Attestation) ? Constants.Constants.Attestation[discipline.Attestation] : ""; AuditoriumHours = discipline.AuditoriumHours; LectureHours = discipline.LectureHours; PracticalHours = discipline.PracticalHours; StudentGroupName = discipline.StudentGroup.Name; var tefd = repo.GetFirstFiltredTeacherForDiscipline(tfd => tfd.Discipline.DisciplineId == discipline.DisciplineId); if (tefd != null) { TeacherFIO = tefd.Teacher.FIO; ScheduleHours = repo.getTFDHours(tefd.TeacherForDisciplineId); } else { TeacherFIO = "нет"; ScheduleHours = 0; } }
public static List<TeacherForDisciplineView> FromTFDList(List<TeacherForDiscipline> list, ScheduleRepository repo) { var result = new List<TeacherForDisciplineView>(); foreach (var tfd in list) { result.Add(new TeacherForDisciplineView() { tfdId = tfd.TeacherForDisciplineId, DisciplineName = tfd.Discipline.Name, GroupName = tfd.Discipline.StudentGroup.Name, PlanHours = tfd.Discipline.AuditoriumHours, Attestation = Constants.Constants.Attestation[tfd.Discipline.Attestation], ScheduleHours = repo.getTFDHours(tfd.TeacherForDisciplineId), HoursDone = repo.GetFiltredLessons(l => l.IsActive && l.TeacherForDiscipline.TeacherForDisciplineId == tfd.TeacherForDisciplineId && (l.Calendar.Date.Date + l.Ring.Time.TimeOfDay) < DateTime.Now).Count * 2 }); } return result; }