| | 1 | | namespace Syki.Shared; |
| | 2 | |
|
| | 3 | | public class CreateAcademicPeriodIn |
| | 4 | | { |
| 3474 | 5 | | public string? Id { get; set; } |
| | 6 | |
|
| | 7 | | /// <summary> |
| | 8 | | /// Data de início |
| | 9 | | /// </summary> |
| 4024 | 10 | | public DateOnly StartAt { get; set; } |
| | 11 | |
|
| | 12 | | /// <summary> |
| | 13 | | /// Data de término |
| | 14 | | /// </summary> |
| 4024 | 15 | | public DateOnly EndAt { get; set; } |
| | 16 | |
|
| 2328 | 17 | | public CreateAcademicPeriodIn() { } |
| | 18 | |
|
| 564 | 19 | | public CreateAcademicPeriodIn(string id) |
| | 20 | | { |
| 564 | 21 | | Id = id; |
| 564 | 22 | | var numbers = id.OnlyNumbers(); |
| 578 | 23 | | if (numbers.Length != 5) return; |
| 550 | 24 | | var year = int.Parse(numbers.Substring(0, 4)); |
| 550 | 25 | | var digit = int.Parse(numbers.Substring(4, 1)); |
| 550 | 26 | | StartAt = digit == 1 ? new DateOnly(year, 02, 01) : new DateOnly(year, 06, 01); |
| 550 | 27 | | EndAt = digit == 1 ? new DateOnly(year, 07, 01) : new DateOnly(year, 12, 01); |
| 550 | 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 | | } |