| | | 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 | | { |
| | 26258 | 10 | | public Guid Id { get; set; } |
| | 12962 | 11 | | public Guid ClassId { get; set; } |
| | 39076 | 12 | | public int Number { get; set; } |
| | 39440 | 13 | | public DateOnly Date { get; set; } |
| | 26138 | 14 | | public Hour StartAt { get; set; } |
| | 26138 | 15 | | public Hour EndAt { get; set; } |
| | 26732 | 16 | | public ClassLessonStatus Status { get; set; } |
| | 39154 | 17 | | public List<ClassLessonAttendance> Attendances { get; set; } |
| | | 18 | | |
| | 28012 | 19 | | private ClassLesson() {} |
| | | 20 | | |
| | 12758 | 21 | | public ClassLesson( |
| | 12758 | 22 | | Guid classId, |
| | 12758 | 23 | | int number, |
| | 12758 | 24 | | DateOnly date, |
| | 12758 | 25 | | Hour startAt, |
| | 12758 | 26 | | Hour endAt |
| | 12758 | 27 | | ) { |
| | 12758 | 28 | | Id = Guid.CreateVersion7(); |
| | 12758 | 29 | | ClassId = classId; |
| | 12758 | 30 | | Number = number; |
| | 12758 | 31 | | Date = date; |
| | 12758 | 32 | | StartAt = startAt; |
| | 12758 | 33 | | EndAt = endAt; |
| | 12758 | 34 | | Status = ClassLessonStatus.Pending; |
| | 12758 | 35 | | } |
| | | 36 | | |
| | | 37 | | public void Finish() |
| | | 38 | | { |
| | 206 | 39 | | Status = ClassLessonStatus.Finalized; |
| | 206 | 40 | | } |
| | | 41 | | |
| | | 42 | | private string GetSchedule() |
| | | 43 | | { |
| | 13302 | 44 | | return $"{Date.DayOfWeek.ToString().ToEnum<Day>().GetDescription()} {StartAt.GetDescription()}-{EndAt.GetDescrip |
| | | 45 | | } |
| | | 46 | | |
| | | 47 | | private decimal GetFrequency() |
| | | 48 | | { |
| | 13302 | 49 | | var total = Attendances.Count; |
| | 26604 | 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 | | { |
| | 13302 | 57 | | return new() |
| | 13302 | 58 | | { |
| | 13302 | 59 | | Id = Id, |
| | 13302 | 60 | | Number = Number, |
| | 13302 | 61 | | Date = Date, |
| | 13302 | 62 | | Status = Status, |
| | 13302 | 63 | | Schedule = GetSchedule(), |
| | 13302 | 64 | | Frequency = GetFrequency(), |
| | 13302 | 65 | | }; |
| | | 66 | | } |
| | | 67 | | } |