summaryrefslogtreecommitdiff
path: root/Codemerx/Gestor.Application/Servicos/Ajuda/AjudaServico.cs
blob: 30e8886df69c40c25894cb3d88f5628ab50399b5 (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
using CsQuery.ExtensionMethods.Internal;
using Gestor.Application.Helpers;
using Gestor.Application.Model.Ajuda;
using Gestor.Application.Servicos.Generic;
using Gestor.Model.License;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;

namespace Gestor.Application.Servicos.Ajuda
{
	public class AjudaServico : BaseServico
	{
		public AjudaServico()
		{
		}

		internal async Task<ObservableCollection<Atendimento>> BuscarAtendimentos(string status)
		{
			ObservableCollection<Atendimento> observableCollection = await Task.Run<ObservableCollection<Atendimento>>(() => {
				ObservableCollection<Atendimento> result;
				try
				{
					result = Connection.Get<ObservableCollection<Atendimento>>(string.Format("Attendance/{0}", (status == "PENDENTES" ? 1 : 2)), true, false).Result;
				}
				catch (Exception exception)
				{
					result = null;
				}
				return result;
			});
			return observableCollection;
		}

		internal async Task<List<Boleto>> BuscarBoletosNotas(string status)
		{
			List<Boleto> boletos = await Task.Run<List<Boleto>>(() => {
				List<Boleto> result;
				try
				{
					result = Connection.Get<List<Boleto>>(string.Format("Billet/{0}", status == "BAIXADOS"), true, false).Result;
				}
				catch (Exception exception)
				{
					result = null;
				}
				return result;
			});
			return boletos;
		}

		internal async Task<Contrato> BuscarContrato(Produto produto)
		{
			Contrato contrato = await Task.Run<Contrato>(() => {
				Contrato result;
				try
				{
					result = Connection.Get<Contrato>(string.Format("Contract/{0}", ExtensionMethods.GetValue(produto)), true, false).Result;
				}
				catch (Exception exception)
				{
					result = null;
				}
				return result;
			});
			return contrato;
		}

		internal async Task<string> BuscarCorpoAtendimentos(long id)
		{
			string str = await Task.Run<string>(() => {
				string result;
				try
				{
					result = Connection.Get<string>(string.Format("Attendance/Body/{0}", id), true, false).Result;
				}
				catch (Exception exception)
				{
					result = null;
				}
				return result;
			});
			return str;
		}

		internal async Task<ObservableCollection<Gestor.Application.Model.Ajuda.Instalacao>> BuscarLicencas()
		{
			ObservableCollection<Gestor.Application.Model.Ajuda.Instalacao> observableCollection = await Task.Run<ObservableCollection<Gestor.Application.Model.Ajuda.Instalacao>>(() => {
				ObservableCollection<Gestor.Application.Model.Ajuda.Instalacao> result;
				try
				{
					result = Connection.Get<ObservableCollection<Gestor.Application.Model.Ajuda.Instalacao>>(string.Format("License/{0}", ApplicationHelper.IdFornecedor), true, false).Result;
				}
				catch (Exception exception)
				{
					result = null;
				}
				return result;
			});
			return observableCollection;
		}

		internal async Task<bool> ExcluirInstalacao(long id)
		{
			int num = 3;
			bool flag = await Task.Run<bool>(() => {
				bool result;
				while (num > 0)
				{
					try
					{
						result = Connection.Delete(string.Format("License/{0}", id)).Result;
					}
					catch (Exception exception)
					{
						num = base.Registrar(exception, 273, num, id, true);
						continue;
					}
					return result;
				}
				return false;
			});
			return flag;
		}
	}
}