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