summaryrefslogtreecommitdiff
path: root/Codemerx/Gestor.Model/Model.Domain.Seguros/ResponsavelAssinatura.cs
blob: 68966803ea582a3ba4156f54a73577328c392168 (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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
using Gestor.Model.Domain.Generic;
using Gestor.Model.Helper;
using Gestor.Model.Resources;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;

namespace Gestor.Model.Domain.Seguros
{
	public class ResponsavelAssinatura : DomainBase, IDomain
	{
		public string DocumentoResponsavel
		{
			get;
			set;
		}

		public string EmailResponsavel
		{
			get;
			set;
		}

		public long IdCliente
		{
			get;
			set;
		}

		public string NomeResponsavel
		{
			get;
			set;
		}

		[JsonIgnore]
		public Func<List<KeyValuePair<string, string>>> ValidationEvent
		{
			get
			{
				ResponsavelAssinatura responsavelAssinatura = this;
				return new Func<List<KeyValuePair<string, string>>>(responsavelAssinatura.Validate);
			}
		}

		public ResponsavelAssinatura()
		{
		}

		public List<KeyValuePair<string, string>> Validate()
		{
			int? nullable;
			int? nullable1;
			List<KeyValuePair<string, string>> keyValuePairs = ValidationHelper.AddValue();
			if (string.IsNullOrWhiteSpace(this.NomeResponsavel))
			{
				nullable = null;
				nullable1 = nullable;
			}
			else
			{
				string nomeResponsavel = this.NomeResponsavel;
				if (nomeResponsavel != null)
				{
					nullable1 = new int?((int)nomeResponsavel.Trim().Split(new char[] { ' ' }).Length);
				}
				else
				{
					nullable = null;
					nullable1 = nullable;
				}
			}
			int? nullable2 = nullable1;
			if (nullable2.HasValue)
			{
				nullable = nullable2;
				if (nullable.GetValueOrDefault() <= 1 & nullable.HasValue)
				{
					keyValuePairs.AddValue<string, string>("NomeResponsavel", Messages.NomeInvalido, true);
				}
			}
			if (!string.IsNullOrWhiteSpace(this.DocumentoResponsavel) && !this.DocumentoResponsavel.ValidacaoDocumento())
			{
				keyValuePairs.AddValue<string, string>("DocumentoResponsavel", Messages.Invalido, true);
			}
			if (!string.IsNullOrWhiteSpace(this.EmailResponsavel) && !this.EmailResponsavel.ValidacaoEmail())
			{
				keyValuePairs.AddValue<string, string>("EmailResponsavel", Messages.Invalido, true);
			}
			if (nullable2.HasValue || !string.IsNullOrWhiteSpace(this.DocumentoResponsavel) || !string.IsNullOrWhiteSpace(this.EmailResponsavel))
			{
				if (!nullable2.HasValue)
				{
					keyValuePairs.AddValue<string, string>("NomeResponsavel", Messages.Obrigatorio, true);
				}
				if (string.IsNullOrWhiteSpace(this.DocumentoResponsavel))
				{
					keyValuePairs.AddValue<string, string>("DocumentoResponsavel", Messages.Obrigatorio, true);
				}
				if (string.IsNullOrWhiteSpace(this.EmailResponsavel))
				{
					keyValuePairs.AddValue<string, string>("EmailResponsavel", Messages.Obrigatorio, true);
				}
			}
			return keyValuePairs;
		}
	}
}