| | 1 | | using Syki.Back.Features.Teacher.CreateLessonAttendance; |
| | 2 | |
|
| | 3 | | namespace Syki.Back.Features.Academic.CreateClass; |
| | 4 | |
|
| | 5 | | /// <summary> |
| | 6 | | /// Representa uma Aula dentro de uma Turma. |
| | 7 | | /// </summary> |
| | 8 | | public class Lesson |
| | 9 | | { |
| 14945 | 10 | | public Guid Id { get; set; } |
| 9833 | 11 | | public Guid ClassId { get; set; } |
| 25218 | 12 | | public DateOnly Date { get; set; } |
| 20028 | 13 | | public Hour StartAt { get; set; } |
| 14913 | 14 | | public Hour EndAt { get; set; } |
| 15198 | 15 | | public LessonStatus Status { get; set; } |
| 14045 | 16 | | public List<LessonAttendance> Attendances { get; set; } |
| | 17 | |
|
| 9759 | 18 | | public Lesson( |
| 9759 | 19 | | Guid classId, |
| 9759 | 20 | | DateOnly date, |
| 9759 | 21 | | Hour startAt, |
| 9759 | 22 | | Hour endAt |
| 9759 | 23 | | ) { |
| 9759 | 24 | | Id = Guid.NewGuid(); |
| 9759 | 25 | | ClassId = classId; |
| 9759 | 26 | | Date = date; |
| 9759 | 27 | | StartAt = startAt; |
| 9759 | 28 | | EndAt = endAt; |
| 9759 | 29 | | Status = LessonStatus.Pending; |
| 9759 | 30 | | } |
| | 31 | |
|
| | 32 | | public void Finish() |
| | 33 | | { |
| 75 | 34 | | Status = LessonStatus.Finalized; |
| 75 | 35 | | } |
| | 36 | |
|
| | 37 | | private string GetSchedule() |
| | 38 | | { |
| 5115 | 39 | | return $"{Date.DayOfWeek.ToString().ToEnum<Day>().GetDescription()} {StartAt.GetDescription()}-{EndAt.GetDescrip |
| | 40 | | } |
| | 41 | |
|
| | 42 | | private decimal GetFrequency() |
| | 43 | | { |
| 5115 | 44 | | var total = Attendances.Count; |
| 10230 | 45 | | if (total == 0) return 0.00M; |
| 0 | 46 | | var presences = Attendances.Count(x => x.Present); |
| 0 | 47 | | return 100M*(1M * presences / (1M * total)); |
| | 48 | | } |
| | 49 | |
|
| | 50 | | public LessonOut ToOut(int number) |
| | 51 | | { |
| 5115 | 52 | | return new() |
| 5115 | 53 | | { |
| 5115 | 54 | | Id = Id, |
| 5115 | 55 | | Number = number, |
| 5115 | 56 | | Date = Date, |
| 5115 | 57 | | Status = Status, |
| 5115 | 58 | | Schedule = GetSchedule(), |
| 5115 | 59 | | Frequency = GetFrequency(), |
| 5115 | 60 | | }; |
| | 61 | | } |
| | 62 | | } |