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.Generic/TelefoneBase.cs | |
| parent | 225aa1499e37faf9d38257caabbadc68d78b427e (diff) | |
| download | gestor-0440c722a221b8068bbf388c1c0c51f0faff0451.tar.gz gestor-0440c722a221b8068bbf388c1c0c51f0faff0451.zip | |
Diffstat (limited to 'Gestor.Model/Gestor.Model.Domain.Generic/TelefoneBase.cs')
| -rw-r--r-- | Gestor.Model/Gestor.Model.Domain.Generic/TelefoneBase.cs | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/Gestor.Model/Gestor.Model.Domain.Generic/TelefoneBase.cs b/Gestor.Model/Gestor.Model.Domain.Generic/TelefoneBase.cs new file mode 100644 index 0000000..04cbea5 --- /dev/null +++ b/Gestor.Model/Gestor.Model.Domain.Generic/TelefoneBase.cs @@ -0,0 +1,61 @@ +using System.Collections.Generic; +using Gestor.Model.Attributes; +using Gestor.Model.Common; +using Gestor.Model.Helper; +using Gestor.Model.Resources; + +namespace Gestor.Model.Domain.Generic; + +public class TelefoneBase : DomainBase +{ + private string _numero; + + private string _prefixo; + + [Log(true)] + public TipoTelefone? Tipo { get; set; } + + [Log(true)] + public string Prefixo + { + get + { + return _prefixo?.ToUpper().Trim(); + } + set + { + _prefixo = value; + } + } + + [Log(true)] + public string Numero + { + get + { + return _numero?.ToUpper().Trim(); + } + set + { + _numero = value; + } + } + + public List<KeyValuePair<string, string>> ValidateBase(bool obrigatorio = true) + { + List<KeyValuePair<string, string>> list = ValidationHelper.AddValue(); + if (Tipo.HasValue && Tipo.GetValueOrDefault() != TipoTelefone.Gratuita && Tipo.GetValueOrDefault() != TipoTelefone.Internacional && Tipo.GetValueOrDefault() != TipoTelefone.Outros && Tipo.GetValueOrDefault() != TipoTelefone.Whatsapp && Tipo.GetValueOrDefault() != TipoTelefone.TarifaUnica && Tipo.GetValueOrDefault() != TipoTelefone.Comercial) + { + if (!string.IsNullOrWhiteSpace(Prefixo) && !Prefixo.ValidacaoPrefixo()) + { + list.AddValue("Prefixo|DDD", Messages.Invalido); + } + if (!string.IsNullOrWhiteSpace(Numero) && !Numero.ValidacaoTelefone()) + { + list.AddValue("Numero|TELEFONE", Messages.Invalido); + } + return list; + } + return list; + } +} |