diff options
Diffstat (limited to 'Gestor.Model/Gestor.Model.Domain.Seguros/Item.cs')
| -rw-r--r-- | Gestor.Model/Gestor.Model.Domain.Seguros/Item.cs | 340 |
1 files changed, 340 insertions, 0 deletions
diff --git a/Gestor.Model/Gestor.Model.Domain.Seguros/Item.cs b/Gestor.Model/Gestor.Model.Domain.Seguros/Item.cs new file mode 100644 index 0000000..057fd46 --- /dev/null +++ b/Gestor.Model/Gestor.Model.Domain.Seguros/Item.cs @@ -0,0 +1,340 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Runtime.CompilerServices; +using Gestor.Model.Common; +using Gestor.Model.Domain.Generic; +using Gestor.Model.Helper; +using Gestor.Model.Resources; +using Newtonsoft.Json; + +namespace Gestor.Model.Domain.Seguros; + +public class Item : DomainBase, IDomain, INotifyPropertyChanged +{ + private bool _selecionado; + + private string _descricao; + + private string _status; + + private string _statusInclusao; + + private string _observacao; + + private string _valorCredito; + + private bool _config = true; + + private bool _fabricanteBranco; + + public bool Selecionado + { + get + { + return _selecionado; + } + set + { + if (value != _selecionado) + { + _selecionado = value; + OnPropertyChanged("Selecionado"); + } + } + } + + public Documento Documento { get; set; } + + public long? Substituido { get; set; } + + public long? Substituicao { get; set; } + + public long? Endosso { get; set; } + + public int? Ordem { get; set; } + + public long? IdDocumentoCancelado { get; set; } + + public string Descricao + { + get + { + return _descricao?.ToUpper(); + } + set + { + _descricao = value; + } + } + + public bool Cancelado { get; set; } + + public bool Sinistrado { get; set; } + + public TipoEndosso? TipoEndosso { get; set; } + + public string Status + { + get + { + return _status?.ToUpper(); + } + set + { + _status = value; + } + } + + public string StatusInclusao + { + get + { + return _statusInclusao?.ToUpper(); + } + set + { + _statusInclusao = value; + } + } + + public string Observacao + { + get + { + return _observacao?.ToUpper(); + } + set + { + _observacao = value; + } + } + + public IList<ControleSinistro> Sinistros { get; set; } + + public IList<Cobertura> Coberturas { get; set; } + + public Auto Auto { get; set; } + + public Patrimonial Patrimonial { get; set; } + + public Aeronautico Aeronautico { get; set; } + + public RiscosDiversos RiscosDiversos { get; set; } + + public Granizo Granizo { get; set; } + + public Vida Vida { get; set; } + + public Sinistro Sinistro { get; set; } + + public Consorcio Consorcio { get; set; } + + public IList<TitularesVida> Titulares { get; set; } + + [JsonIgnore] + public Func<List<KeyValuePair<string, string>>> ValidationEvent => Validate; + + public event PropertyChangedEventHandler PropertyChanged; + + protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) + { + this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + } + + public List<KeyValuePair<string, string>> Validate(bool config, bool fabricanteBranco = false) + { + _config = config; + _fabricanteBranco = fabricanteBranco; + return Validate(); + } + + public List<KeyValuePair<string, string>> Validate() + { + List<KeyValuePair<string, string>> list = ValidationHelper.AddValue(); + if (!Ordem.HasValue || Ordem == 0) + { + list.AddValue("Ordem", Messages.Invalido); + } + if (string.IsNullOrWhiteSpace(Descricao)) + { + list.AddValue("Descricao", Messages.Obrigatorio); + } + else if (Descricao.Length > 250) + { + list.AddValue("Descricao", string.Format(Messages.MaiorQueLimite, 250)); + } + if (Documento == null) + { + return list; + } + long id = Documento.Controle.Ramo.Id; + if (id <= 38) + { + long num = id - 1; + if ((ulong)num <= 19uL) + { + switch (num) + { + case 4L: + goto IL_0184; + case 0L: + case 1L: + case 2L: + case 14L: + case 17L: + goto IL_01c5; + case 12L: + goto IL_022f; + case 19L: + goto IL_0264; + case 5L: + case 6L: + case 8L: + case 9L: + goto IL_0299; + case 3L: + case 7L: + case 10L: + case 11L: + case 13L: + case 15L: + case 16L: + case 18L: + goto IL_03f1; + } + } + long num2 = id - 30; + if ((ulong)num2 <= 8uL) + { + switch (num2) + { + case 7L: + break; + case 0L: + goto IL_01c5; + case 8L: + goto IL_01fa; + case 1L: + goto IL_033d; + case 6L: + goto IL_03c2; + default: + goto IL_03f1; + } + goto IL_0184; + } + } + else if (id == 47 || id == 53 || id == 66) + { + goto IL_0299; + } + goto IL_03f1; + IL_0264: + if (Granizo == null) + { + list.AddValue("Granizo", Messages.Obrigatorio); + } + else + { + list.AddRange(Granizo.Validate()); + } + goto IL_041e; + IL_01fa: + if (Patrimonial == null) + { + list.AddValue("Patrimonial", Messages.Obrigatorio); + } + else + { + list.AddRange(Patrimonial.ValidateGarantia()); + } + goto IL_041e; + IL_01c5: + if (Patrimonial == null) + { + list.AddValue("Patrimonial", Messages.Obrigatorio); + } + else + { + list.AddRange(Patrimonial.Validate()); + } + goto IL_041e; + IL_03f1: + if (RiscosDiversos == null) + { + list.AddValue("RiscosDiversos", Messages.Obrigatorio); + } + else + { + list.AddRange(RiscosDiversos.Validate()); + } + goto IL_041e; + IL_033d: + if (RiscosDiversos == null) + { + list.AddValue("RiscosDiversos", Messages.Obrigatorio); + } + else + { + list.AddRange(RiscosDiversos.Validate()); + } + if (Titulares != null && Titulares.Count > 0) + { + foreach (TitularesVida titulare in Titulares) + { + list.AddRange(titulare.Validate()); + } + } + goto IL_041e; + IL_03c2: + if (Consorcio == null) + { + list.AddValue("Consorcio", Messages.Obrigatorio); + } + else + { + list.AddRange(Consorcio.Validate()); + } + goto IL_041e; + IL_0299: + if (Vida == null) + { + list.AddValue("Vida", Messages.Obrigatorio); + } + else + { + list.AddRange(Vida.Validate()); + } + if (Titulares != null && Titulares.Count > 0 && Documento.Controle.Ramo.Id != 6) + { + foreach (TitularesVida titulare2 in Titulares) + { + list.AddRange(titulare2.Validate()); + } + } + goto IL_041e; + IL_041e: + return list; + IL_022f: + if (Aeronautico == null) + { + list.AddValue("Aeronautico", Messages.Obrigatorio); + } + else + { + list.AddRange(Aeronautico.Validate()); + } + goto IL_041e; + IL_0184: + if (Auto == null) + { + list.AddValue("Auto", Messages.Obrigatorio); + } + else + { + list.AddRange(Auto.Validate(_config, _fabricanteBranco)); + } + goto IL_041e; + } +} |