summaryrefslogtreecommitdiff
path: root/Codemerx/Gestor.Model/Model.Domain.Seguros/Consorcio.cs
blob: 3efd5adb49dbb83b69eb060103c9adba78ed7bad (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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
using Gestor.Model.Domain.Generic;
using Gestor.Model.Helper;
using Gestor.Model.Resources;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Globalization;
using System.Runtime.CompilerServices;

namespace Gestor.Model.Domain.Seguros
{
	public class Consorcio : DomainBase, IDomain
	{
		private string _bensConsorcio;

		private string _grupo;

		private string _cota;

		private decimal? _valorCredito;

		private string _observacao;

		public string BensConsorcio
		{
			get
			{
				string str = this._bensConsorcio;
				if (str != null)
				{
					return str.ToUpper();
				}
				return null;
			}
			set
			{
				this._bensConsorcio = value;
			}
		}

		public string Cota
		{
			get
			{
				string str = this._cota;
				if (str != null)
				{
					return str.ToUpper();
				}
				return null;
			}
			set
			{
				this._cota = value;
			}
		}

		public string Grupo
		{
			get
			{
				string str = this._grupo;
				if (str != null)
				{
					return str.ToUpper();
				}
				return null;
			}
			set
			{
				this._grupo = value;
			}
		}

		public Gestor.Model.Domain.Seguros.Item Item
		{
			get;
			set;
		}

		public string Observacao
		{
			get
			{
				string str = this._observacao;
				if (str != null)
				{
					return str.ToUpper();
				}
				return null;
			}
			set
			{
				this._observacao = value;
			}
		}

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

		public decimal? ValorCredito
		{
			get
			{
				return this._valorCredito;
			}
			set
			{
				this._valorCredito = value;
			}
		}

		public Consorcio()
		{
		}

		public static List<TupleList> Log(Gestor.Model.Domain.Seguros.Item item)
		{
			decimal valueOrDefault;
			string str;
			List<TupleList> tupleLists = new List<TupleList>();
			TupleList tupleList = new TupleList();
			ObservableCollection<Tuple<string, string, string>> observableCollection = new ObservableCollection<Tuple<string, string, string>>()
			{
				new Tuple<string, string, string>("DESCRIÇÃO", (string.IsNullOrWhiteSpace(item.Consorcio.BensConsorcio) ? "" : item.Consorcio.BensConsorcio), ""),
				new Tuple<string, string, string>("GRUPO", (string.IsNullOrWhiteSpace(item.Consorcio.Grupo) ? "" : item.Consorcio.Grupo), ""),
				new Tuple<string, string, string>("COTA", (string.IsNullOrWhiteSpace(item.Consorcio.Cota) ? "" : item.Consorcio.Cota), "")
			};
			decimal? valorCredito = item.Consorcio.ValorCredito;
			if (!valorCredito.HasValue)
			{
				str = "";
			}
			else
			{
				valorCredito = item.Consorcio.ValorCredito;
				if (valorCredito.HasValue)
				{
					valueOrDefault = valorCredito.GetValueOrDefault();
					str = valueOrDefault.ToString("C", new CultureInfo("pt-BR", false));
				}
				else
				{
					str = null;
				}
			}
			observableCollection.Add(new Tuple<string, string, string>("GRUPO", str, ""));
			tupleList.Tuples = observableCollection;
			tupleLists.Add(tupleList);
			List<TupleList> tupleLists1 = tupleLists;
			ObservableCollection<Tuple<string, string, string>> observableCollection1 = new ObservableCollection<Tuple<string, string, string>>()
			{
				new Tuple<string, string, string>("COBERTURAS$", "", "")
			};
			foreach (Cobertura cobertura in item.Coberturas)
			{
				observableCollection1.Add(new Tuple<string, string, string>(string.Format("   COBERTURA {0}$", item.Coberturas.IndexOf(cobertura) + 1), "", ""));
				observableCollection1.Add(new Tuple<string, string, string>("      OBSERVAÇÃO", (string.IsNullOrWhiteSpace(cobertura.Observacao) ? "" : cobertura.Observacao.ToUpper()), ""));
				valueOrDefault = cobertura.Premio;
				observableCollection1.Add(new Tuple<string, string, string>("      PRÊMIO", valueOrDefault.ToString("C", new CultureInfo("pt-BR", false)), ""));
				valueOrDefault = cobertura.Franquia;
				observableCollection1.Add(new Tuple<string, string, string>("      FRANQUIA", valueOrDefault.ToString("C", new CultureInfo("pt-BR", false)), ""));
				valueOrDefault = cobertura.Lmi;
				observableCollection1.Add(new Tuple<string, string, string>("      L.M.I.", valueOrDefault.ToString("C", new CultureInfo("pt-BR", false)), ""));
			}
			tupleLists1.Add(new TupleList()
			{
				Tuples = observableCollection1
			});
			return tupleLists1;
		}

		public List<KeyValuePair<string, string>> Validate()
		{
			List<KeyValuePair<string, string>> keyValuePairs = ValidationHelper.AddValue();
			if (string.IsNullOrWhiteSpace(this.BensConsorcio))
			{
				keyValuePairs.AddValue<string, string>("BensConsorcio", Messages.Obrigatorio, true);
			}
			return keyValuePairs;
		}
	}
}