diff options
Diffstat (limited to 'Gestor.Model/Model.Domain.Seguros/TitularesVida.cs')
| -rw-r--r-- | Gestor.Model/Model.Domain.Seguros/TitularesVida.cs | 269 |
1 files changed, 269 insertions, 0 deletions
diff --git a/Gestor.Model/Model.Domain.Seguros/TitularesVida.cs b/Gestor.Model/Model.Domain.Seguros/TitularesVida.cs new file mode 100644 index 0000000..3956270 --- /dev/null +++ b/Gestor.Model/Model.Domain.Seguros/TitularesVida.cs @@ -0,0 +1,269 @@ +using Gestor.Model.Common;
+using Gestor.Model.Domain.Generic;
+using Gestor.Model.Helper;
+using Gestor.Model.Resources;
+using Gestor.Model.Validation;
+using Newtonsoft.Json;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Runtime.CompilerServices;
+using System.Threading;
+
+namespace Gestor.Model.Domain.Seguros
+{
+ public class TitularesVida : DomainBase, IDomain, INotifyPropertyChanged
+ {
+ private string _codigo;
+
+ private string _fatura;
+
+ private string _nome;
+
+ private string _observacao;
+
+ private string _matricula;
+
+ private decimal? _premio;
+
+ private decimal? _capital;
+
+ private bool _selecionado;
+
+ public decimal? Capital
+ {
+ get
+ {
+ return new decimal?(this._capital.GetValueOrDefault());
+ }
+ set
+ {
+ this._capital = value;
+ }
+ }
+
+ public string Codigo
+ {
+ get
+ {
+ string str = this._codigo;
+ if (str != null)
+ {
+ return str.ToUpper();
+ }
+ return null;
+ }
+ set
+ {
+ this._codigo = value;
+ }
+ }
+
+ public string Cpf
+ {
+ get;
+ set;
+ }
+
+ public TitularesVida Dependente
+ {
+ get;
+ set;
+ }
+
+ public string Fatura
+ {
+ get
+ {
+ string str = this._fatura;
+ if (str != null)
+ {
+ return str.ToUpper();
+ }
+ return null;
+ }
+ set
+ {
+ this._fatura = value;
+ }
+ }
+
+ public DateTime? Fim
+ {
+ get;
+ set;
+ }
+
+ public long IdItem
+ {
+ get;
+ set;
+ }
+
+ public DateTime? Inicio
+ {
+ get;
+ set;
+ }
+
+ public string Matricula
+ {
+ get
+ {
+ string str = this._matricula;
+ if (str != null)
+ {
+ return str.ToUpper();
+ }
+ return null;
+ }
+ set
+ {
+ this._matricula = value;
+ }
+ }
+
+ public DateTime? Nascimento
+ {
+ get;
+ set;
+ }
+
+ public string Nome
+ {
+ get
+ {
+ string str = this._nome;
+ if (str != null)
+ {
+ return str.ToUpper();
+ }
+ return null;
+ }
+ set
+ {
+ this._nome = value;
+ }
+ }
+
+ public string Observacao
+ {
+ get
+ {
+ string str = this._observacao;
+ if (str != null)
+ {
+ return str.ToUpper();
+ }
+ return null;
+ }
+ set
+ {
+ this._observacao = value;
+ }
+ }
+
+ public decimal? Premio
+ {
+ get
+ {
+ return new decimal?(this._premio.GetValueOrDefault());
+ }
+ set
+ {
+ this._premio = value;
+ }
+ }
+
+ public bool Selecionado
+ {
+ get
+ {
+ return this._selecionado;
+ }
+ set
+ {
+ if (value == this._selecionado)
+ {
+ return;
+ }
+ this._selecionado = value;
+ this.OnPropertyChanged("Selecionado");
+ }
+ }
+
+ public TipoTitular? Tipo
+ {
+ get;
+ set;
+ }
+
+ [JsonIgnore]
+ public Func<List<KeyValuePair<string, string>>> ValidationEvent
+ {
+ get
+ {
+ TitularesVida titularesVida = this;
+ return new Func<List<KeyValuePair<string, string>>>(titularesVida.Validate);
+ }
+ }
+
+ public TitularesVida()
+ {
+ }
+
+ protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
+ {
+ PropertyChangedEventHandler propertyChangedEventHandler = this.PropertyChanged;
+ if (propertyChangedEventHandler == null)
+ {
+ return;
+ }
+ propertyChangedEventHandler(this, new PropertyChangedEventArgs(propertyName));
+ }
+
+ public List<KeyValuePair<string, string>> Validate()
+ {
+ List<KeyValuePair<string, string>> keyValuePairs = ValidationHelper.AddValue();
+ if (string.IsNullOrWhiteSpace(this.Nome))
+ {
+ keyValuePairs.AddValue<string, string>("Nome", Messages.Obrigatorio, true);
+ }
+ else if (this.Nome.Length > 150)
+ {
+ keyValuePairs.AddValue<string, string>("Nome", string.Format(Messages.MaiorQueLimite, 150), true);
+ }
+ if (!this.Inicio.HasValue)
+ {
+ keyValuePairs.AddValue<string, string>("Inicio|INÍCIO", Messages.Obrigatorio, true);
+ }
+ else if (DateTime.Compare(this.Inicio.Value, new DateTime(1753, 1, 1)) < 0 || DateTime.Compare(this.Inicio.Value, new DateTime(9999, 12, 31)) > 0)
+ {
+ keyValuePairs.AddValue<string, string>("Inicio|INÍCIO", string.Format(Messages.DataInvalida, Array.Empty<object>()), true);
+ }
+ if (this.Fim.HasValue && (DateTime.Compare(this.Fim.Value, new DateTime(1753, 1, 1)) < 0 || DateTime.Compare(this.Fim.Value, new DateTime(9999, 12, 31)) > 0))
+ {
+ keyValuePairs.AddValue<string, string>("Fim", string.Format(Messages.DataInvalida, Array.Empty<object>()), true);
+ }
+ if (this.Nascimento.HasValue && (DateTime.Compare(this.Nascimento.Value, new DateTime(1753, 1, 1)) < 0 || DateTime.Compare(this.Nascimento.Value, new DateTime(9999, 12, 31)) > 0))
+ {
+ keyValuePairs.AddValue<string, string>("Nascimento", string.Format(Messages.DataInvalida, Array.Empty<object>()), true);
+ }
+ if ((!this.Nascimento.HasValue || Funcoes.GetAge(this.Nascimento.Value) >= 18) && !string.IsNullOrWhiteSpace(this.Cpf) && !this.Cpf.ValidacaoDocumento())
+ {
+ keyValuePairs.AddValue<string, string>("Cpf", Messages.Invalido, true);
+ }
+ if (!this.Tipo.HasValue)
+ {
+ keyValuePairs.AddValue<string, string>("Tipo", Messages.Obrigatorio, true);
+ }
+ if (this.Tipo.GetValueOrDefault() == TipoTitular.Dependente && this.Dependente == null)
+ {
+ keyValuePairs.AddValue<string, string>("Dependente", "OBRIGATÓRIO. PESQUISE POR UM DOS TITULARES\nQUE SEJA DO TIPO SÓCIO OU FUNCIONÁRIO", true);
+ }
+ return keyValuePairs;
+ }
+
+ public event PropertyChangedEventHandler PropertyChanged;
+ }
+}
\ No newline at end of file |