diff options
| author | Lucas Faria Mendes <lucas.fariamo08@gmail.com> | 2026-03-30 17:17:46 +0000 |
|---|---|---|
| committer | Lucas Faria Mendes <lucas.fariamo08@gmail.com> | 2026-03-30 17:17:46 +0000 |
| commit | 0440c722a221b8068bbf388c1c0c51f0faff0451 (patch) | |
| tree | 169cbf90c50ff7961db82ecb606c50c2a45a1688 /Gestor.Model/Gestor.Model.Domain.Seguros/Aeronautico.cs | |
| parent | 225aa1499e37faf9d38257caabbadc68d78b427e (diff) | |
| download | gestor-0440c722a221b8068bbf388c1c0c51f0faff0451.tar.gz gestor-0440c722a221b8068bbf388c1c0c51f0faff0451.zip | |
Diffstat (limited to 'Gestor.Model/Gestor.Model.Domain.Seguros/Aeronautico.cs')
| -rw-r--r-- | Gestor.Model/Gestor.Model.Domain.Seguros/Aeronautico.cs | 297 |
1 files changed, 297 insertions, 0 deletions
diff --git a/Gestor.Model/Gestor.Model.Domain.Seguros/Aeronautico.cs b/Gestor.Model/Gestor.Model.Domain.Seguros/Aeronautico.cs new file mode 100644 index 0000000..d780cb4 --- /dev/null +++ b/Gestor.Model/Gestor.Model.Domain.Seguros/Aeronautico.cs @@ -0,0 +1,297 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Globalization; +using Gestor.Model.Common; +using Gestor.Model.Domain.Generic; +using Gestor.Model.Helper; +using Gestor.Model.Resources; +using Gestor.Model.Validation; +using Newtonsoft.Json; + +namespace Gestor.Model.Domain.Seguros; + +public class Aeronautico : DomainBase, IDomain +{ + private string _fabricante; + + private string _modelo; + + private string _serie; + + private string _prefixo; + + private string _marinaAero; + + private string _certificado; + + private string _casco; + + private string _navegacao; + + private string _observacao; + + public Item Item { get; set; } + + public TipoAeronautico Tipo { get; set; } + + public string Fabricante + { + get + { + return _fabricante?.ToUpper(); + } + set + { + _fabricante = value; + } + } + + public string Modelo + { + get + { + return _modelo?.ToUpper(); + } + set + { + _modelo = value; + } + } + + public string Serie + { + get + { + return _serie?.ToUpper(); + } + set + { + _serie = value; + } + } + + public string Prefixo + { + get + { + return _prefixo?.ToUpper(); + } + set + { + _prefixo = value; + } + } + + public int? Fabricacao { get; set; } + + public int? Tripulantes { get; set; } + + public int? Passageiros { get; set; } + + public string MarinaAero + { + get + { + return _marinaAero?.ToUpper(); + } + set + { + _marinaAero = value; + } + } + + public long? Peso { get; set; } + + public string Certificado + { + get + { + return _certificado?.ToUpper(); + } + set + { + _certificado = value; + } + } + + public DateTime? Vistoria { get; set; } + + public string Casco + { + get + { + return _casco?.ToUpper(); + } + set + { + _casco = value; + } + } + + public string Navegacao + { + get + { + return _navegacao?.ToUpper(); + } + set + { + _navegacao = value; + } + } + + public string Observacao + { + get + { + return _observacao?.ToUpper(); + } + set + { + _observacao = value; + } + } + + [JsonIgnore] + public Func<List<KeyValuePair<string, string>>> ValidationEvent => Validate; + + public List<KeyValuePair<string, string>> Validate() + { + List<KeyValuePair<string, string>> list = ValidationHelper.AddValue(); + if (string.IsNullOrWhiteSpace(Fabricante)) + { + list.AddValue("Fabricante", Messages.Obrigatorio); + } + else if (Fabricante != null && Fabricante.Length > 60) + { + list.AddValue("Fabricante", string.Format(Messages.MaiorQueLimite, 60)); + } + if (Tipo == (TipoAeronautico)0) + { + list.AddValue("Tipo", Messages.Obrigatorio); + } + if (string.IsNullOrWhiteSpace(Modelo)) + { + list.AddValue("Modelo", Messages.Obrigatorio); + } + else if (Modelo.Length > 60) + { + list.AddValue("Modelo", string.Format(Messages.MaiorQueLimite, 60)); + } + if (Vistoria.HasValue && (DateTime.Compare(Vistoria.Value, new DateTime(1753, 1, 1)) < 0 || DateTime.Compare(Vistoria.Value, new DateTime(9999, 12, 31)) > 0)) + { + list.AddValue("Vistoria", string.Format(Messages.DataInvalida)); + } + if (string.IsNullOrWhiteSpace(Serie)) + { + list.AddValue("Serie", Messages.Obrigatorio); + } + else if (Serie.Length > 30) + { + list.AddValue("Serie", string.Format(Messages.MaiorQueLimite, 30)); + } + if (string.IsNullOrWhiteSpace(Prefixo)) + { + list.AddValue("Prefixo", Messages.Obrigatorio); + } + else if (Prefixo.Length > 30) + { + list.AddValue("Prefixo", string.Format(Messages.MaiorQueLimite, 30)); + } + if (!Fabricacao.HasValue) + { + list.AddValue("Fabricacao", Messages.Obrigatorio); + } + else if (!Fabricacao.Value.ToString().ValidacaoFabricacao()) + { + list.AddValue("Fabricacao", Messages.Invalido); + } + if (!Tripulantes.HasValue) + { + list.AddValue("Tripulantes", Messages.Obrigatorio); + } + if (!Passageiros.HasValue) + { + list.AddValue("Passageiros", Messages.Obrigatorio); + } + if (string.IsNullOrWhiteSpace(MarinaAero)) + { + list.AddValue("MarinaAero", Messages.Obrigatorio); + } + else if (MarinaAero.Length > 60) + { + list.AddValue("MarinaAero", string.Format(Messages.MaiorQueLimite, 60)); + } + if (!string.IsNullOrWhiteSpace(Certificado) && Certificado.Length > 60) + { + list.AddValue("Certificado", string.Format(Messages.MaiorQueLimite, 60)); + } + if (string.IsNullOrWhiteSpace(Casco) && Tipo.Categoria() == "Aero") + { + list.AddValue("Casco", Messages.Obrigatorio); + } + else if (Tipo.Categoria() != "Aero" && Casco != null && Casco.Length > 60) + { + list.AddValue("Casco", string.Format(Messages.MaiorQueLimite, 60)); + } + if (!string.IsNullOrWhiteSpace(Navegacao) && Tipo.Categoria() != "Aero" && Navegacao.Length > 60) + { + list.AddValue("Navegacao", string.Format(Messages.MaiorQueLimite, 60)); + } + if (!Vistoria.HasValue && Tipo.Categoria() == "Aero") + { + list.AddValue("Vistoria", Messages.Obrigatorio); + } + if (!Peso.HasValue && Tipo.Categoria() == "Aero") + { + list.AddValue("Peso", Messages.Obrigatorio); + } + return list; + } + + public static List<TupleList> Log(Item item) + { + List<TupleList> list = new List<TupleList> + { + new TupleList + { + Tuples = new ObservableCollection<Tuple<string, string, string>> + { + new Tuple<string, string, string>("TIPO DE AERONAVE", item.Aeronautico.Tipo.GetDescription(), ""), + new Tuple<string, string, string>("FABRICANTE", string.IsNullOrWhiteSpace(item.Aeronautico.Fabricante) ? "" : item.Aeronautico.Fabricante.ToUpper(), ""), + new Tuple<string, string, string>("MODELO", string.IsNullOrWhiteSpace(item.Aeronautico.Modelo) ? "" : item.Aeronautico.Modelo.ToUpper(), ""), + new Tuple<string, string, string>("REGISTRO", string.IsNullOrWhiteSpace(item.Aeronautico.Serie) ? "" : item.Aeronautico.Serie.ToUpper(), ""), + new Tuple<string, string, string>("PREFIXO", string.IsNullOrWhiteSpace(item.Aeronautico.Prefixo) ? "" : item.Aeronautico.Prefixo.ToUpper(), ""), + new Tuple<string, string, string>("ANO DE FABRICAÇÃO", (!item.Aeronautico.Fabricacao.HasValue) ? "" : item.Aeronautico.Fabricacao?.ToString(), ""), + new Tuple<string, string, string>("TRIPULANTES", (!item.Aeronautico.Tripulantes.HasValue) ? "" : item.Aeronautico.Tripulantes?.ToString(), ""), + new Tuple<string, string, string>("PASSAGEIROS", (!item.Aeronautico.Passageiros.HasValue) ? "" : item.Aeronautico.Passageiros?.ToString(), ""), + new Tuple<string, string, string>("AERÓDROMO", string.IsNullOrWhiteSpace(item.Aeronautico.MarinaAero) ? "" : item.Aeronautico.MarinaAero.ToUpper(), ""), + new Tuple<string, string, string>("PESO", (!item.Aeronautico.Peso.HasValue) ? "" : item.Aeronautico.Peso?.ToString(), ""), + new Tuple<string, string, string>("NAVEGAÇÃO", string.IsNullOrWhiteSpace(item.Aeronautico.Navegacao) ? "" : item.Aeronautico.Navegacao.ToUpper(), ""), + new Tuple<string, string, string>("CERTIFICADO", string.IsNullOrWhiteSpace(item.Aeronautico.Certificado) ? "" : item.Aeronautico.Certificado.ToUpper(), ""), + new Tuple<string, string, string>("MATERIAL DO CASCO", string.IsNullOrWhiteSpace(item.Aeronautico.Casco) ? "" : item.Aeronautico.Casco.ToUpper(), ""), + new Tuple<string, string, string>("VALIDADE DA VISTORIA", (!item.Aeronautico.Vistoria.HasValue) ? "" : item.Aeronautico.Vistoria?.ToShortDateString(), ""), + new Tuple<string, string, string>("OBSERVAÇÃO", string.IsNullOrWhiteSpace(item.Aeronautico.Observacao) ? "" : item.Aeronautico.Observacao.ToUpper(), "") + } + } + }; + ObservableCollection<Tuple<string, string, string>> observableCollection = new ObservableCollection<Tuple<string, string, string>> + { + new Tuple<string, string, string>("COBERTURAS$", "", "") + }; + foreach (Cobertura cobertura in item.Coberturas) + { + observableCollection.Add(new Tuple<string, string, string>($" COBERTURA {item.Coberturas.IndexOf(cobertura) + 1}$", "", "")); + observableCollection.Add(new Tuple<string, string, string>(" OBSERVAÇÃO", string.IsNullOrWhiteSpace(cobertura.Observacao) ? "" : cobertura.Observacao.ToUpper(), "")); + observableCollection.Add(new Tuple<string, string, string>(" PRÊMIO", cobertura.Premio.ToString("C", new CultureInfo("pt-BR", useUserOverride: false)), "")); + observableCollection.Add(new Tuple<string, string, string>(" FRANQUIA", cobertura.Franquia.ToString("C", new CultureInfo("pt-BR", useUserOverride: false)), "")); + observableCollection.Add(new Tuple<string, string, string>(" L.M.I.", cobertura.Lmi.ToString("C", new CultureInfo("pt-BR", useUserOverride: false)), "")); + } + list.Add(new TupleList + { + Tuples = observableCollection + }); + return list; + } +} |