using Gestor.Model.Common; using Gestor.Model.Domain.Generic; using Gestor.Model.Helper; using Gestor.Model.Resources; using Newtonsoft.Json; using System; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Runtime.CompilerServices; using System.Threading; 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 Gestor.Model.Domain.Seguros.Aeronautico Aeronautico { get; set; } public Gestor.Model.Domain.Seguros.Auto Auto { get; set; } public bool Cancelado { get; set; } public IList Coberturas { get; set; } public Gestor.Model.Domain.Seguros.Consorcio Consorcio { get; set; } public string Descricao { get { string str = this._descricao; if (str != null) { return str.ToUpper(); } return null; } set { this._descricao = value; } } public Gestor.Model.Domain.Seguros.Documento Documento { get; set; } public long? Endosso { get; set; } public Gestor.Model.Domain.Seguros.Granizo Granizo { get; set; } public long? IdDocumentoCancelado { get; set; } public string Observacao { get { string str = this._observacao; if (str != null) { return str.ToUpper(); } return null; } set { this._observacao = value; } } public int? Ordem { get; set; } public Gestor.Model.Domain.Seguros.Patrimonial Patrimonial { get; set; } public Gestor.Model.Domain.Seguros.RiscosDiversos RiscosDiversos { get; set; } public bool Selecionado { get { return this._selecionado; } set { if (value == this._selecionado) { return; } this._selecionado = value; this.OnPropertyChanged("Selecionado"); } } public bool Sinistrado { get; set; } public Gestor.Model.Domain.Seguros.Sinistro Sinistro { get; set; } public IList Sinistros { get; set; } public string Status { get { string str = this._status; if (str != null) { return str.ToUpper(); } return null; } set { this._status = value; } } public string StatusInclusao { get { string str = this._statusInclusao; if (str != null) { return str.ToUpper(); } return null; } set { this._statusInclusao = value; } } public long? Substituicao { get; set; } public long? Substituido { get; set; } public Gestor.Model.Common.TipoEndosso? TipoEndosso { get; set; } public IList Titulares { get; set; } [JsonIgnore] public Func>> ValidationEvent { get { Item item = this; return new Func>>(item.Validate); } } public Gestor.Model.Domain.Seguros.Vida Vida { get; set; } public Item() { } protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) { PropertyChangedEventHandler propertyChangedEventHandler = this.PropertyChanged; if (propertyChangedEventHandler == null) { return; } propertyChangedEventHandler(this, new PropertyChangedEventArgs(propertyName)); } public List> Validate(bool config, bool fabricanteBranco = false) { this._config = config; this._fabricanteBranco = fabricanteBranco; return this.Validate(); } public List> Validate() { List> keyValuePairs = ValidationHelper.AddValue(); int? ordem = this.Ordem; if (ordem.HasValue) { ordem = this.Ordem; if (!(ordem.GetValueOrDefault() == 0 & ordem.HasValue)) { goto Label0; } } keyValuePairs.AddValue("Ordem", Messages.Invalido, true); if (string.IsNullOrWhiteSpace(this.Descricao)) { keyValuePairs.AddValue("Descricao", Messages.Obrigatorio, true); } else if (this.Descricao.Length > 250) { keyValuePairs.AddValue("Descricao", string.Format(Messages.MaiorQueLimite, 250), true); } if (this.Documento == null) { return keyValuePairs; } long id = this.Documento.Controle.Ramo.Id; if (id > (long)38) { if (id == (long)47 || id == (long)53 || id == (long)66) { goto Label1; } goto Label2; } else { long num = id - (long)1; if (num <= (long)19) { switch ((uint)num) { case 0: case 1: case 2: case 14: case 17: { goto Label4; } case 3: case 7: case 10: case 11: case 13: case 15: case 16: case 18: { goto Label2; } case 4: { goto Label5; } case 5: case 6: case 8: case 9: { goto Label1; } case 12: { if (this.Aeronautico != null) { keyValuePairs.AddRange(this.Aeronautico.Validate()); return keyValuePairs; } else { keyValuePairs.AddValue("Aeronautico", Messages.Obrigatorio, true); return keyValuePairs; } } case 19: { if (this.Granizo != null) { keyValuePairs.AddRange(this.Granizo.Validate()); return keyValuePairs; } else { keyValuePairs.AddValue("Granizo", Messages.Obrigatorio, true); return keyValuePairs; } } } } else { } long num1 = id - (long)30; if (num1 <= (long)8) { switch ((uint)num1) { case 0: { break; } case 1: { if (this.RiscosDiversos != null) { keyValuePairs.AddRange(this.RiscosDiversos.Validate()); } else { keyValuePairs.AddValue("RiscosDiversos", Messages.Obrigatorio, true); } if (this.Titulares == null || this.Titulares.Count <= 0) { return keyValuePairs; } using (IEnumerator enumerator = this.Titulares.GetEnumerator()) { while (enumerator.MoveNext()) { keyValuePairs.AddRange(enumerator.Current.Validate()); } return keyValuePairs; } break; } case 6: { if (this.Consorcio != null) { keyValuePairs.AddRange(this.Consorcio.Validate()); return keyValuePairs; } else { keyValuePairs.AddValue("Consorcio", Messages.Obrigatorio, true); return keyValuePairs; } } case 7: { goto Label5; } case 8: { if (this.Patrimonial != null) { keyValuePairs.AddRange(this.Patrimonial.ValidateGarantia()); return keyValuePairs; } else { keyValuePairs.AddValue("Patrimonial", Messages.Obrigatorio, true); return keyValuePairs; } } default: { goto Label2; } } } else { goto Label2; } Label4: if (this.Patrimonial != null) { keyValuePairs.AddRange(this.Patrimonial.Validate()); } else { keyValuePairs.AddValue("Patrimonial", Messages.Obrigatorio, true); } } return keyValuePairs; Label1: if (this.Vida != null) { keyValuePairs.AddRange(this.Vida.Validate()); } else { keyValuePairs.AddValue("Vida", Messages.Obrigatorio, true); } if (this.Titulares != null && this.Titulares.Count > 0 && this.Documento.Controle.Ramo.Id != (long)6) { using (enumerator = this.Titulares.GetEnumerator()) { while (enumerator.MoveNext()) { keyValuePairs.AddRange(enumerator.Current.Validate()); } return keyValuePairs; } } else { return keyValuePairs; } Label2: if (this.RiscosDiversos != null) { keyValuePairs.AddRange(this.RiscosDiversos.Validate()); return keyValuePairs; } else { keyValuePairs.AddValue("RiscosDiversos", Messages.Obrigatorio, true); return keyValuePairs; } Label5: if (this.Auto != null) { keyValuePairs.AddRange(this.Auto.Validate(this._config, this._fabricanteBranco)); return keyValuePairs; } else { keyValuePairs.AddValue("Auto", Messages.Obrigatorio, true); return keyValuePairs; } } public event PropertyChangedEventHandler PropertyChanged; } }