summaryrefslogtreecommitdiff
path: root/Gestor.Model/Gestor.Model.Domain.Seguros/SeguradoraEndereco.cs
blob: 9839df5eb8ff4dd630c0ee4c2faa89b61f3299f9 (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
using System;
using System.Collections.Generic;
using Gestor.Model.Common;
using Gestor.Model.Domain.Common;
using Gestor.Model.Domain.Generic;
using Gestor.Model.Helper;
using Gestor.Model.Resources;
using Newtonsoft.Json;

namespace Gestor.Model.Domain.Seguros;

public class SeguradoraEndereco : EnderecoBase, IDomain
{
	public Empresa Empresa { get; set; }

	public Seguradora Seguradora { get; set; }

	public TipoEndereco Tipo { get; set; }

	[JsonIgnore]
	public Func<List<KeyValuePair<string, string>>> ValidationEvent => Validate;

	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.Estado))
		{
			list.AddValue("Estado", Messages.Obrigatorio);
		}
		else if (!base.Estado.ValidacaoEstado())
		{
			list.AddValue("Estado", Messages.Invalido);
		}
		if (string.IsNullOrWhiteSpace(base.Endereco))
		{
			list.AddValue("Endereco", Messages.Obrigatorio);
		}
		else if (base.Endereco.Length > 60)
		{
			list.AddValue("Endereco", string.Format(Messages.MaiorQueLimite, 60));
		}
		if (string.IsNullOrWhiteSpace(base.Numero))
		{
			list.AddValue("Numero", Messages.Obrigatorio);
		}
		else if (base.Numero.Length > 5)
		{
			list.AddValue("Numero", string.Format(Messages.MaiorQueLimite, 5));
		}
		if (string.IsNullOrWhiteSpace(base.Bairro))
		{
			list.AddValue("Bairro", Messages.Obrigatorio);
		}
		else if (base.Bairro.Length > 60)
		{
			list.AddValue("Bairro", string.Format(Messages.MaiorQueLimite, 60));
		}
		if (string.IsNullOrWhiteSpace(base.Cidade))
		{
			list.AddValue("Cidade", Messages.Obrigatorio);
		}
		else if (base.Cidade.Length > 30)
		{
			list.AddValue("Cidade", string.Format(Messages.MaiorQueLimite, 30));
		}
		string complemento = base.Complemento;
		if (complemento != null && complemento.Length > 30)
		{
			list.AddValue("Complemento", string.Format(Messages.MaiorQueLimite, 30));
		}
		return list;
	}
}