summaryrefslogtreecommitdiff
path: root/Gestor.Application/Converters/EnderecoConverter.cs
blob: d31f10e32efb4c9ca35858f8a383ba7ab0dc318c (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.Domain.Seguros;
using System;
using System.Collections.ObjectModel;
using System.Globalization;
using System.Windows.Data;
using System.Windows.Markup;

namespace Gestor.Application.Converters
{
	public class EnderecoConverter : MarkupExtension, IValueConverter
	{
		public EnderecoConverter()
		{
		}

		public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
		{
			string str;
			string str1;
			string str2;
			string str3;
			string str4;
			string str5;
			string str6;
			string str7;
			string str8;
			string str9;
			string str10;
			string str11;
			if (value == null)
			{
				return "";
			}
			if (!(value is ObservableCollection<ClienteEndereco>))
			{
				return "";
			}
			ObservableCollection<ClienteEndereco> observableCollection = (ObservableCollection<ClienteEndereco>)value;
			if (string.IsNullOrWhiteSpace(observableCollection[0].get_Complemento()))
			{
				string[] strArrays = new string[11];
				string endereco = observableCollection[0].get_Endereco();
				if (endereco != null)
				{
					str = endereco.Trim();
				}
				else
				{
					str = null;
				}
				strArrays[0] = str;
				strArrays[1] = ", ";
				string numero = observableCollection[0].get_Numero();
				if (numero != null)
				{
					str1 = numero.Trim();
				}
				else
				{
					str1 = null;
				}
				strArrays[2] = str1;
				strArrays[3] = ", ";
				string bairro = observableCollection[0].get_Bairro();
				if (bairro != null)
				{
					str2 = bairro.Trim();
				}
				else
				{
					str2 = null;
				}
				strArrays[4] = str2;
				strArrays[5] = " - ";
				string cidade = observableCollection[0].get_Cidade();
				if (cidade != null)
				{
					str3 = cidade.Trim();
				}
				else
				{
					str3 = null;
				}
				strArrays[6] = str3;
				strArrays[7] = "/";
				string estado = observableCollection[0].get_Estado();
				if (estado != null)
				{
					str4 = estado.Trim();
				}
				else
				{
					str4 = null;
				}
				strArrays[8] = str4;
				strArrays[9] = " - ";
				string cep = observableCollection[0].get_Cep();
				if (cep != null)
				{
					str5 = cep.Trim();
				}
				else
				{
					str5 = null;
				}
				strArrays[10] = str5;
				return string.Concat(strArrays);
			}
			string[] strArrays1 = new string[13];
			string endereco1 = observableCollection[0].get_Endereco();
			if (endereco1 != null)
			{
				str6 = endereco1.Trim();
			}
			else
			{
				str6 = null;
			}
			strArrays1[0] = str6;
			strArrays1[1] = ", ";
			string numero1 = observableCollection[0].get_Numero();
			if (numero1 != null)
			{
				str7 = numero1.Trim();
			}
			else
			{
				str7 = null;
			}
			strArrays1[2] = str7;
			strArrays1[3] = ", ";
			strArrays1[4] = observableCollection[0].get_Complemento().Trim();
			strArrays1[5] = ", ";
			string bairro1 = observableCollection[0].get_Bairro();
			if (bairro1 != null)
			{
				str8 = bairro1.Trim();
			}
			else
			{
				str8 = null;
			}
			strArrays1[6] = str8;
			strArrays1[7] = " - ";
			string cidade1 = observableCollection[0].get_Cidade();
			if (cidade1 != null)
			{
				str9 = cidade1.Trim();
			}
			else
			{
				str9 = null;
			}
			strArrays1[8] = str9;
			strArrays1[9] = "/";
			string estado1 = observableCollection[0].get_Estado();
			if (estado1 != null)
			{
				str10 = estado1.Trim();
			}
			else
			{
				str10 = null;
			}
			strArrays1[10] = str10;
			strArrays1[11] = " - ";
			string cep1 = observableCollection[0].get_Cep();
			if (cep1 != null)
			{
				str11 = cep1.Trim();
			}
			else
			{
				str11 = null;
			}
			strArrays1[12] = str11;
			return string.Concat(strArrays1);
		}

		public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
		{
			return null;
		}

		public override object ProvideValue(IServiceProvider serviceProvider)
		{
			return this;
		}
	}
}