| | 1 | | namespace Syki.Back.Features.Academic.CreateEnrollmentPeriod; |
| | 2 | |
|
| | 3 | | public class EnrollmentPeriod |
| | 4 | | { |
| 701 | 5 | | public string Id { get; set; } |
| 235 | 6 | | public Guid InstitutionId { get; set; } |
| 542 | 7 | | public DateOnly StartAt { get; set; } |
| 699 | 8 | | public DateOnly EndAt { get; set; } |
| | 9 | |
|
| 233 | 10 | | public EnrollmentPeriod( |
| 233 | 11 | | string id, |
| 233 | 12 | | Guid institutionId, |
| 233 | 13 | | DateOnly startAt, |
| 233 | 14 | | DateOnly endAt |
| 233 | 15 | | ) { |
| 233 | 16 | | Id = id; |
| 233 | 17 | | InstitutionId = institutionId; |
| 233 | 18 | | StartAt = startAt; |
| 233 | 19 | | EndAt = endAt; |
| 233 | 20 | | } |
| | 21 | |
|
| | 22 | | public static OneOf<EnrollmentPeriod, SykiError> New( |
| | 23 | | string id, |
| | 24 | | Guid institutionId, |
| | 25 | | DateOnly startAt, |
| | 26 | | DateOnly endAt |
| | 27 | | ) { |
| 65 | 28 | | if (startAt >= endAt) |
| 6 | 29 | | return new InvalidEnrollmentPeriodDates(); |
| | 30 | |
|
| 59 | 31 | | return new EnrollmentPeriod(id, institutionId, startAt, endAt); |
| | 32 | | } |
| | 33 | |
|
| | 34 | | public OneOf<SykiSuccess, SykiError> Update(DateOnly startAt, DateOnly endAt) |
| | 35 | | { |
| 39 | 36 | | if (startAt >= endAt) |
| 2 | 37 | | return new InvalidEnrollmentPeriodDates(); |
| | 38 | |
|
| 37 | 39 | | StartAt = startAt; |
| 37 | 40 | | EndAt = endAt; |
| | 41 | |
|
| 37 | 42 | | return new SykiSuccess(); |
| | 43 | | } |
| | 44 | |
|
| | 45 | | public EnrollmentPeriodOut ToOut() |
| | 46 | | { |
| 98 | 47 | | return new() |
| 98 | 48 | | { |
| 98 | 49 | | Id = Id, |
| 98 | 50 | | StartAt = StartAt, |
| 98 | 51 | | EndAt = EndAt, |
| 98 | 52 | | }; |
| | 53 | | } |
| | 54 | | } |