| | | 1 | | namespace Syki.Shared; |
| | | 2 | | |
| | | 3 | | public class CreateAcademicPeriodIn : IApiDto<CreateAcademicPeriodIn> |
| | | 4 | | { |
| | 3534 | 5 | | public string? Id { get; set; } |
| | | 6 | | |
| | | 7 | | /// <summary> |
| | | 8 | | /// Data de início |
| | | 9 | | /// </summary> |
| | 4074 | 10 | | public DateOnly StartAt { get; set; } |
| | | 11 | | |
| | | 12 | | /// <summary> |
| | | 13 | | /// Data de término |
| | | 14 | | /// </summary> |
| | 4074 | 15 | | public DateOnly EndAt { get; set; } |
| | | 16 | | |
| | 2384 | 17 | | public CreateAcademicPeriodIn() { } |
| | | 18 | | |
| | 554 | 19 | | public CreateAcademicPeriodIn(string id) |
| | | 20 | | { |
| | 554 | 21 | | Id = id; |
| | 554 | 22 | | var numbers = id.OnlyNumbers(); |
| | 568 | 23 | | if (numbers.Length != 5) return; |
| | 540 | 24 | | var year = int.Parse(numbers.Substring(0, 4)); |
| | 540 | 25 | | var digit = int.Parse(numbers.Substring(4, 1)); |
| | 540 | 26 | | StartAt = digit == 1 ? new DateOnly(year, 02, 01) : new DateOnly(year, 06, 01); |
| | 540 | 27 | | EndAt = digit == 1 ? new DateOnly(year, 07, 01) : new DateOnly(year, 12, 01); |
| | 540 | 28 | | } |
| | | 29 | | |
| | | 30 | | public static IEnumerable<(string, CreateAcademicPeriodIn)> GetExamples() => |
| | 0 | 31 | | [ |
| | 0 | 32 | | ("2024.1", new() { Id = "2024.1", StartAt = new(2024, 02, 01), EndAt = new(2024, 06, 05) }), |
| | 0 | 33 | | ("2024.2", new() { Id = "2024.2", StartAt = new(2024, 07, 08), EndAt = new(2024, 12, 10) }), |
| | 0 | 34 | | ]; |
| | | 35 | | } |