| | 1 | | using Syki.Back.Features.Teacher.CreateLessonAttendance; |
| | 2 | |
|
| | 3 | | namespace Syki.Back.Features.Academic.CreateClass; |
| | 4 | |
|
| | 5 | | /// <summary> |
| | 6 | | /// Aula |
| | 7 | | /// </summary> |
| | 8 | | public class ClassLesson |
| | 9 | | { |
| 26948 | 10 | | public Guid Id { get; set; } |
| 13306 | 11 | | public Guid ClassId { get; set; } |
| 40168 | 12 | | public int Number { get; set; } |
| 40476 | 13 | | public DateOnly Date { get; set; } |
| 26828 | 14 | | public Hour StartAt { get; set; } |
| 26828 | 15 | | public Hour EndAt { get; set; } |
| 27448 | 16 | | public ClassLessonStatus Status { get; set; } |
| 40252 | 17 | | public List<ClassLessonAttendance> Attendances { get; set; } |
| | 18 | |
|
| 28704 | 19 | | private ClassLesson() {} |
| | 20 | |
|
| 13102 | 21 | | public ClassLesson( |
| 13102 | 22 | | Guid classId, |
| 13102 | 23 | | int number, |
| 13102 | 24 | | DateOnly date, |
| 13102 | 25 | | Hour startAt, |
| 13102 | 26 | | Hour endAt |
| 13102 | 27 | | ) { |
| 13102 | 28 | | Id = Guid.CreateVersion7(); |
| 13102 | 29 | | ClassId = classId; |
| 13102 | 30 | | Number = number; |
| 13102 | 31 | | Date = date; |
| 13102 | 32 | | StartAt = startAt; |
| 13102 | 33 | | EndAt = endAt; |
| 13102 | 34 | | Status = ClassLessonStatus.Pending; |
| 13102 | 35 | | } |
| | 36 | |
|
| | 37 | | public void Finish() |
| | 38 | | { |
| 206 | 39 | | Status = ClassLessonStatus.Finalized; |
| 206 | 40 | | } |
| | 41 | |
|
| | 42 | | private string GetSchedule() |
| | 43 | | { |
| 13648 | 44 | | return $"{Date.DayOfWeek.ToString().ToEnum<Day>().GetDescription()} {StartAt.GetDescription()}-{EndAt.GetDescrip |
| | 45 | | } |
| | 46 | |
|
| | 47 | | private decimal GetFrequency() |
| | 48 | | { |
| 13648 | 49 | | var total = Attendances.Count; |
| 27296 | 50 | | if (total == 0) return 0.00M; |
| 0 | 51 | | var presences = Attendances.Count(x => x.Present); |
| 0 | 52 | | return 100M*(1M * presences / (1M * total)); |
| | 53 | | } |
| | 54 | |
|
| | 55 | | public ClassLessonOut ToOut() |
| | 56 | | { |
| 13648 | 57 | | return new() |
| 13648 | 58 | | { |
| 13648 | 59 | | Id = Id, |
| 13648 | 60 | | Number = Number, |
| 13648 | 61 | | Date = Date, |
| 13648 | 62 | | Status = Status, |
| 13648 | 63 | | Schedule = GetSchedule(), |
| 13648 | 64 | | Frequency = GetFrequency(), |
| 13648 | 65 | | }; |
| | 66 | | } |
| | 67 | | } |