summaryrefslogtreecommitdiff
path: root/Gestor.Model/Model.Domain.Generic/TelefoneBase.cs
blob: 23f0cbe947977875223f1871dd4bb98961cb7cdb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
using Gestor.Model.Attributes;
using Gestor.Model.Common;
using Gestor.Model.Helper;
using Gestor.Model.Resources;
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;

namespace Gestor.Model.Domain.Generic
{
	public class TelefoneBase : DomainBase
	{
		private string _numero;

		private string _prefixo;

		[Log(true)]
		public string Numero
		{
			get
			{
				string str = this._numero;
				if (str == null)
				{
					return null;
				}
				return str.ToUpper().Trim();
			}
			set
			{
				this._numero = value;
			}
		}

		[Log(true)]
		public string Prefixo
		{
			get
			{
				string str = this._prefixo;
				if (str == null)
				{
					return null;
				}
				return str.ToUpper().Trim();
			}
			set
			{
				this._prefixo = value;
			}
		}

		[Log(true)]
		public TipoTelefone? Tipo
		{
			get;
			set;
		}

		public TelefoneBase()
		{
		}

		public List<KeyValuePair<string, string>> ValidateBase(bool obrigatorio = true)
		{
			List<KeyValuePair<string, string>> keyValuePairs = ValidationHelper.AddValue();
			if (!this.Tipo.HasValue || this.Tipo.GetValueOrDefault() == TipoTelefone.Gratuita || this.Tipo.GetValueOrDefault() == TipoTelefone.Internacional || this.Tipo.GetValueOrDefault() == TipoTelefone.Outros || this.Tipo.GetValueOrDefault() == TipoTelefone.Whatsapp || this.Tipo.GetValueOrDefault() == TipoTelefone.TarifaUnica || this.Tipo.GetValueOrDefault() == TipoTelefone.Comercial)
			{
				return keyValuePairs;
			}
			if (!string.IsNullOrWhiteSpace(this.Prefixo) && !this.Prefixo.ValidacaoPrefixo())
			{
				keyValuePairs.AddValue<string, string>("Prefixo|DDD", Messages.Invalido, true);
			}
			if (!string.IsNullOrWhiteSpace(this.Numero) && !this.Numero.ValidacaoTelefone())
			{
				keyValuePairs.AddValue<string, string>("Numero|TELEFONE", Messages.Invalido, true);
			}
			return keyValuePairs;
		}
	}
}