diff options
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; + } +} |