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.Generic; using System.ComponentModel; using System.Runtime.CompilerServices; using System.Threading; namespace Gestor.Model.Domain.Seguros { public class DetalheExtrato : DomainBase, IDomain, INotifyPropertyChanged { private bool _selecionado; private string _cliente; private string _apolice; private string _endosso; private string _numeroParcela; private string _historico; public bool IsNormal = true; public string Apolice { get { string str = this._apolice; if (str == null) { return null; } return str.ToUpper().Trim(); } set { this._apolice = value; } } public string Cliente { get { string str = this._cliente; if (str != null) { return str.ToUpper(); } return null; } set { this._cliente = value; } } public decimal? Comissao { get; set; } public bool Corrigir { get; set; } public DateTime? Credito { get; set; } public long? Documento { get; set; } public string Endosso { get { string str = this._endosso; if (str == null) { return null; } return str.ToUpper().Trim(); } set { this._endosso = value; } } public Gestor.Model.Domain.Seguros.Extrato Extrato { get; set; } public string Historico { get { string str = this._historico; if (str != null) { return str.ToUpper(); } return null; } set { this._historico = value; } } public string NumeroParcela { get { string str = this._numeroParcela; if (str == null) { return null; } return str.ToUpper().Trim(); } set { this._numeroParcela = value; } } public long? Parcela { get; set; } public DateTime? Recebimento { get; set; } public bool Selecionado { get { return this._selecionado; } set { this._selecionado = value; this.OnPropertyChanged("Selecionado"); } } public StatusParcela? Status { get; set; } public Gestor.Model.Common.SubTipo? SubTipo { get; set; } [JsonIgnore] public Func>> ValidationEvent { get { DetalheExtrato detalheExtrato = this; return new Func>>(detalheExtrato.Validate); } } public decimal? Valor { get; set; } public decimal? ValorComissao { get; set; } public DetalheExtrato() { } protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) { PropertyChangedEventHandler propertyChangedEventHandler = this.PropertyChanged; if (propertyChangedEventHandler == null) { return; } propertyChangedEventHandler(this, new PropertyChangedEventArgs(propertyName)); } public List> Validate() { List> keyValuePairs = ValidationHelper.AddValue(); if (this.Recebimento.HasValue && (DateTime.Compare(this.Recebimento.Value, new DateTime(1753, 1, 1)) < 0 || DateTime.Compare(this.Recebimento.Value, new DateTime(9999, 12, 31)) > 0)) { keyValuePairs.AddValue("Recebimento", string.Format(Messages.DataInvalida, Array.Empty()), true); } if (this.Credito.HasValue && (DateTime.Compare(this.Credito.Value, new DateTime(1753, 1, 1)) < 0 || DateTime.Compare(this.Credito.Value, new DateTime(9999, 12, 31)) > 0)) { keyValuePairs.AddValue("Credito", string.Format(Messages.DataInvalida, Array.Empty()), true); } if (string.IsNullOrWhiteSpace(this.Cliente) && this.Cliente.Length > 100) { keyValuePairs.AddValue("Cliente", string.Format(Messages.MaiorQueLimite, 100), true); } if (string.IsNullOrWhiteSpace(this.Apolice) && this.Apolice.Length > 30) { keyValuePairs.AddValue("Apolice", string.Format(Messages.MaiorQueLimite, 30), true); } if (string.IsNullOrWhiteSpace(this.Endosso) && this.Endosso.Length > 20) { keyValuePairs.AddValue("Endosso", string.Format(Messages.MaiorQueLimite, 20), true); } if (string.IsNullOrWhiteSpace(this.NumeroParcela) && this.NumeroParcela.Length > 4) { keyValuePairs.AddValue("NumeroParcela", string.Format(Messages.MaiorQueLimite, 4), true); } return keyValuePairs; } public event PropertyChangedEventHandler PropertyChanged; } }