| | 1 | | namespace Syki.Back.Features.Academic.CreateCampus; |
| | 2 | |
|
| | 3 | | /// <summary> |
| | 4 | | /// Campus |
| | 5 | | /// </summary> |
| | 6 | | public class Campus |
| | 7 | | { |
| 614 | 8 | | public Guid Id { get; set; } |
| 292 | 9 | | public Guid InstitutionId { get; set; } |
| 1104 | 10 | | public string Name { get; set; } |
| 598 | 11 | | public BrazilState State { get; set; } |
| 598 | 12 | | public string City { get; set; } |
| 598 | 13 | | public int Capacity { get; set; } |
| | 14 | |
|
| 1036 | 15 | | private Campus() { } |
| | 16 | |
|
| 292 | 17 | | public Campus(Guid institutionId, string name, BrazilState state, string city, int capacity) |
| | 18 | | { |
| 292 | 19 | | Id = Guid.CreateVersion7(); |
| 292 | 20 | | InstitutionId = institutionId; |
| 292 | 21 | | Name = name; |
| 292 | 22 | | State = state; |
| 292 | 23 | | City = city; |
| 292 | 24 | | Capacity = capacity; |
| 292 | 25 | | } |
| | 26 | |
|
| | 27 | | public static OneOf<Campus, SykiError> New( |
| | 28 | | Guid institutionId, |
| | 29 | | string name, |
| | 30 | | BrazilState state, |
| | 31 | | string city, |
| | 32 | | int capacity |
| | 33 | | ) { |
| 290 | 34 | | if (capacity <= 0) return new InvalidCampusCapacity(); |
| | 35 | |
|
| 290 | 36 | | return new Campus(institutionId, name, state, city, capacity); |
| | 37 | | } |
| | 38 | |
|
| | 39 | | public void Update(string name, BrazilState state, string city, int capacity) |
| | 40 | | { |
| 4 | 41 | | Name = name; |
| 4 | 42 | | State = state; |
| 4 | 43 | | City = city; |
| 4 | 44 | | Capacity = capacity; |
| 4 | 45 | | } |
| | 46 | |
|
| | 47 | | public CampusOut ToOut() |
| | 48 | | { |
| 302 | 49 | | return new() |
| 302 | 50 | | { |
| 302 | 51 | | Id = Id, |
| 302 | 52 | | Name = Name, |
| 302 | 53 | | State = State, |
| 302 | 54 | | City = City, |
| 302 | 55 | | Capacity = Capacity, |
| 302 | 56 | | }; |
| | 57 | | } |
| | 58 | |
|
| | 59 | | public GetAcademicTeacherCampusOut ToGetAcademicTeacherCampusOut() |
| | 60 | | { |
| 0 | 61 | | return new() |
| 0 | 62 | | { |
| 0 | 63 | | Id = Id, |
| 0 | 64 | | Name = $"{Name} ({City} - {State})", |
| 0 | 65 | | }; |
| | 66 | | } |
| | 67 | | } |