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 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 bool Selecionado { get { return _selecionado; } set { _selecionado = value; OnPropertyChanged("Selecionado"); } } public Extrato Extrato { get; set; } public long? Documento { get; set; } public long? Parcela { get; set; } public StatusParcela? Status { get; set; } public SubTipo? SubTipo { get; set; } public bool Corrigir { get; set; } public string Cliente { get { return _cliente?.ToUpper(); } set { _cliente = value; } } public string Apolice { get { return _apolice?.ToUpper().Trim(); } set { _apolice = value; } } public string Endosso { get { return _endosso?.ToUpper().Trim(); } set { _endosso = value; } } public string NumeroParcela { get { return _numeroParcela?.ToUpper().Trim(); } set { _numeroParcela = value; } } public DateTime? Recebimento { get; set; } public DateTime? Credito { get; set; } public decimal? Valor { get; set; } public decimal? Comissao { get; set; } public decimal? ValorComissao { get; set; } public string Historico { get { return _historico?.ToUpper(); } set { _historico = value; } } [JsonIgnore] public Func>> ValidationEvent => Validate; public event PropertyChangedEventHandler PropertyChanged; protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) { this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); } public List> Validate() { List> list = ValidationHelper.AddValue(); if (Recebimento.HasValue && (DateTime.Compare(Recebimento.Value, new DateTime(1753, 1, 1)) < 0 || DateTime.Compare(Recebimento.Value, new DateTime(9999, 12, 31)) > 0)) { list.AddValue("Recebimento", string.Format(Messages.DataInvalida)); } if (Credito.HasValue && (DateTime.Compare(Credito.Value, new DateTime(1753, 1, 1)) < 0 || DateTime.Compare(Credito.Value, new DateTime(9999, 12, 31)) > 0)) { list.AddValue("Credito", string.Format(Messages.DataInvalida)); } if (string.IsNullOrWhiteSpace(Cliente) && Cliente.Length > 100) { list.AddValue("Cliente", string.Format(Messages.MaiorQueLimite, 100)); } if (string.IsNullOrWhiteSpace(Apolice) && Apolice.Length > 30) { list.AddValue("Apolice", string.Format(Messages.MaiorQueLimite, 30)); } if (string.IsNullOrWhiteSpace(Endosso) && Endosso.Length > 20) { list.AddValue("Endosso", string.Format(Messages.MaiorQueLimite, 20)); } if (string.IsNullOrWhiteSpace(NumeroParcela) && NumeroParcela.Length > 4) { list.AddValue("NumeroParcela", string.Format(Messages.MaiorQueLimite, 4)); } return list; } }