| | | 1 | | using Estud.Back.Domain.Periods; |
| | | 2 | | using Estud.Back.Domain.Teachers; |
| | | 3 | | using Estud.Back.Domain.Students; |
| | | 4 | | using Estud.Back.Domain.Disciplines; |
| | | 5 | | |
| | | 6 | | namespace Estud.Back.Domain.Classes; |
| | | 7 | | |
| | | 8 | | /// <summary> |
| | | 9 | | /// Turma |
| | | 10 | | /// </summary> |
| | | 11 | | public class Class |
| | | 12 | | { |
| | 12 | 13 | | public int Id { get; set; } |
| | 8 | 14 | | public int InstitutionId { get; set; } |
| | | 15 | | |
| | 8 | 16 | | public int DisciplineId { get; set; } |
| | 4 | 17 | | public Discipline Discipline { get; set; } |
| | | 18 | | |
| | 0 | 19 | | public int PeriodId { get; set; } |
| | 1236 | 20 | | public AcademicPeriod Period { get; set; } |
| | | 21 | | |
| | 12 | 22 | | public int Vacancies { get; set; } |
| | 22 | 23 | | public ClassStatus Status { get; set; } |
| | 336 | 24 | | public int Workload { get; set; } |
| | | 25 | | |
| | 8 | 26 | | public int? CampusId { get; set; } |
| | | 27 | | |
| | 8 | 28 | | public int? TeacherId { get; set; } |
| | 4 | 29 | | public EstudTeacher Teacher { get; set; } |
| | | 30 | | |
| | 20 | 31 | | public List<Schedule> Schedules { get; set; } |
| | 176 | 32 | | public List<ClassLesson> Lessons { get; set; } |
| | 8 | 33 | | public List<EstudStudent> Students { get; set; } |
| | | 34 | | |
| | 12 | 35 | | private Class() {} |
| | | 36 | | |
| | 8 | 37 | | public Class( |
| | 8 | 38 | | int institutionId, |
| | 8 | 39 | | int disciplineId, |
| | 8 | 40 | | int? campusId, |
| | 8 | 41 | | int? teacherId, |
| | 8 | 42 | | AcademicPeriod period, |
| | 8 | 43 | | int vacancies, |
| | 8 | 44 | | List<Schedule> schedules |
| | 8 | 45 | | ) { |
| | 8 | 46 | | InstitutionId = institutionId; |
| | 8 | 47 | | DisciplineId = disciplineId; |
| | 8 | 48 | | CampusId = campusId; |
| | 8 | 49 | | TeacherId = teacherId; |
| | 8 | 50 | | Period = period; |
| | 8 | 51 | | Vacancies = vacancies; |
| | 8 | 52 | | Status = ClassStatus.OnPreEnrollment; |
| | 8 | 53 | | Schedules = schedules; |
| | 8 | 54 | | Lessons = []; |
| | 8 | 55 | | Students = []; |
| | 8 | 56 | | } |
| | | 57 | | |
| | | 58 | | public void CreateLessons() |
| | | 59 | | { |
| | 8 | 60 | | var schedules = Schedules.OrderBy(x => x.Day).ThenBy(x => x.Start).ToList(); |
| | | 61 | | |
| | 8 | 62 | | var number = 1; |
| | 8 | 63 | | var current = Period.StartAt; |
| | 1216 | 64 | | while (current < Period.EndAt) |
| | | 65 | | { |
| | 4832 | 66 | | foreach (var schedule in schedules) |
| | | 67 | | { |
| | 1208 | 68 | | if (current.DayOfWeek.Is(schedule.Day)) |
| | | 69 | | { |
| | 168 | 70 | | Lessons.Add(new(this, number, current, schedule.Start, schedule.End)); |
| | 168 | 71 | | Workload += schedule.GetDiff(); |
| | 168 | 72 | | number++; |
| | | 73 | | } |
| | | 74 | | } |
| | 1208 | 75 | | current = current.AddDays(1); |
| | | 76 | | } |
| | 8 | 77 | | } |
| | | 78 | | } |