diff options
| author | Lucas Faria Mendes <lucas.fariamo08@gmail.com> | 2026-03-30 17:17:46 +0000 |
|---|---|---|
| committer | Lucas Faria Mendes <lucas.fariamo08@gmail.com> | 2026-03-30 17:17:46 +0000 |
| commit | 0440c722a221b8068bbf388c1c0c51f0faff0451 (patch) | |
| tree | 169cbf90c50ff7961db82ecb606c50c2a45a1688 /Gestor.Model/Gestor.Model.Domain.Seguros/ClienteEndereco.cs | |
| parent | 225aa1499e37faf9d38257caabbadc68d78b427e (diff) | |
| download | gestor-master.tar.gz gestor-master.zip | |
Diffstat (limited to 'Gestor.Model/Gestor.Model.Domain.Seguros/ClienteEndereco.cs')
| -rw-r--r-- | Gestor.Model/Gestor.Model.Domain.Seguros/ClienteEndereco.cs | 123 |
1 files changed, 123 insertions, 0 deletions
diff --git a/Gestor.Model/Gestor.Model.Domain.Seguros/ClienteEndereco.cs b/Gestor.Model/Gestor.Model.Domain.Seguros/ClienteEndereco.cs new file mode 100644 index 0000000..c2086be --- /dev/null +++ b/Gestor.Model/Gestor.Model.Domain.Seguros/ClienteEndereco.cs @@ -0,0 +1,123 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Runtime.CompilerServices; +using Gestor.Model.Attributes; +using Gestor.Model.Domain.Generic; +using Gestor.Model.Helper; +using Gestor.Model.Resources; +using Newtonsoft.Json; + +namespace Gestor.Model.Domain.Seguros; + +public class ClienteEndereco : EnderecoBase, IDomain, INotifyPropertyChanged +{ + private bool _selecionado; + + private string _observacao; + + public bool Selecionado + { + get + { + return _selecionado; + } + set + { + if (value != _selecionado) + { + _selecionado = value; + OnPropertyChanged("Selecionado"); + } + } + } + + [Log(true)] + public string Observacao + { + get + { + return _observacao?.ToUpper(); + } + set + { + _observacao = value; + } + } + + public Cliente Cliente { get; set; } + + public int? Ordem { 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() + { + List<KeyValuePair<string, string>> list = ValidationHelper.AddValue(); + if (string.IsNullOrWhiteSpace(base.Cep)) + { + list.AddValue("Cep", Messages.Obrigatorio); + } + else if (!base.Cep.ValidacaoCep()) + { + list.AddValue("Cep", Messages.Invalido); + } + if (string.IsNullOrWhiteSpace(base.Endereco)) + { + list.AddValue("Endereco", Messages.Obrigatorio); + } + else if (base.Endereco.Length > 150) + { + list.AddValue("Endereco", string.Format(Messages.MaiorQueLimite, 150)); + } + if (string.IsNullOrWhiteSpace(base.Numero)) + { + list.AddValue("Numero", Messages.Obrigatorio); + } + else if (base.Numero.Length > 6) + { + list.AddValue("Numero", string.Format(Messages.MaiorQueLimite, 6)); + } + if (!string.IsNullOrWhiteSpace(base.Complemento) && base.Complemento.Length > 45) + { + list.AddValue("Complemento", string.Format(Messages.MaiorQueLimite, 45)); + } + if (string.IsNullOrWhiteSpace(base.Bairro)) + { + list.AddValue("Bairro", Messages.Obrigatorio); + } + else if (base.Bairro.Length > 100) + { + list.AddValue("Bairro", string.Format(Messages.MaiorQueLimite, 100)); + } + if (string.IsNullOrWhiteSpace(base.Cidade)) + { + list.AddValue("Cidade", Messages.Obrigatorio); + } + else if (base.Cidade.Length > 50) + { + list.AddValue("Cidade", string.Format(Messages.MaiorQueLimite, 50)); + } + if (string.IsNullOrWhiteSpace(base.Estado)) + { + list.AddValue("Estado", Messages.Obrigatorio); + } + else if (!base.Estado.ValidacaoEstado()) + { + list.AddValue("Estado", Messages.Invalido); + } + if (!string.IsNullOrWhiteSpace(Observacao) && Observacao.Length > 255) + { + list.AddValue("Observacao", string.Format(Messages.MaiorQueLimite, 255)); + } + return list; + } +} |