| | | 1 | | using System.ComponentModel.DataAnnotations; |
| | | 2 | | using System.Data; |
| | | 3 | | using System.Text.Json.Serialization; |
| | | 4 | | using Common.Core.Classes; |
| | | 5 | | |
| | | 6 | | namespace Common.Core.Models; |
| | | 7 | | |
| | | 8 | | /// <summary>Province details.</summary> |
| | | 9 | | public class Province : ModelData |
| | | 10 | | { |
| | | 11 | | /// <inheritdoc/> |
| | 1 | 12 | | public override int Id { get; set; } |
| | | 13 | | |
| | | 14 | | /// <summary>Province code.</summary> |
| | | 15 | | [MaxLength( 10 )] |
| | | 16 | | [JsonIgnore( Condition = JsonIgnoreCondition.WhenWritingNull )] |
| | 32 | 17 | | public string? Code { get; set; } |
| | | 18 | | |
| | | 19 | | /// <summary>Province name.</summary> |
| | | 20 | | [Required] |
| | | 21 | | [MaxLength( 50 )] |
| | 51 | 22 | | public string Name { get; set; } = string.Empty; |
| | | 23 | | |
| | | 24 | | /// <summary>Builds a Province object from a database table row.</summary> |
| | | 25 | | /// <param name="row">Database row containing the Province columns.</param> |
| | | 26 | | /// <returns>Province object containing the database values.</returns> |
| | | 27 | | /// <remarks>This method assumes that the table column names are the same as the property names.</remarks> |
| | | 28 | | public static Province Read( DataRow row ) |
| | 1 | 29 | | { |
| | 1 | 30 | | return new Province() |
| | 1 | 31 | | { |
| | 1 | 32 | | Id = row.Field<int>( nameof( Id ) ), |
| | 1 | 33 | | Code = row.Field<string?>( nameof( Code ) ), |
| | 1 | 34 | | Name = row.Field<string>( nameof( Name ) )! |
| | 1 | 35 | | }; |
| | 1 | 36 | | } |
| | | 37 | | } |