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
|
using Gestor.Application.Helpers;
using Gestor.Application.Servicos.Generic;
using Gestor.Infrastructure.Repository.Interface;
using Gestor.Infrastructure.UnitOfWork.Generic;
using Gestor.Infrastructure.UnitOfWork.Logic;
using Gestor.Model.Domain.Common;
using Gestor.Model.Domain.Generic;
using Gestor.Model.Domain.Seguros;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
namespace Gestor.Application.Servicos.Ferramentas
{
internal class EstipulanteServico : BaseServico
{
public EstipulanteServico()
{
}
internal async Task<Estipulante> BuscarEstipulantePorId(long id)
{
int num = 3;
Estipulante estipulante1 = await Task.Run<Estipulante>(() => {
Estipulante estipulante;
while (num > 0)
{
try
{
using (UnitOfWork read = Instancia.Read)
{
estipulante = read.get_EstipulanteRepository().FindById(id);
}
}
catch (Exception exception)
{
num = base.Registrar(exception, 110, num, id, true);
continue;
}
return estipulante;
}
return new Estipulante();
});
return estipulante1;
}
public async Task<bool> Delete(Estipulante estipulante)
{
int num = 3;
bool flag1 = await Task.Run<bool>(() => {
bool flag;
while (num > 0)
{
List<RegistroLog> registroLogs = new List<RegistroLog>();
try
{
using (UnitOfWork commited = Instancia.Commited)
{
registroLogs.Add(base.CreateLog(estipulante.get_Id(), estipulante.GetValorOriginal(), 9, 2));
commited.get_EstipulanteRepository().Delete(estipulante.get_Id());
base.SaveLog(registroLogs, commited);
commited.Commit();
flag = true;
}
}
catch (Exception exception)
{
num = base.Registrar(exception, 220, num, estipulante, true);
continue;
}
return flag;
}
return false;
});
return flag1;
}
public async Task<Estipulante> Save(Estipulante estipulante)
{
int num = 3;
base.Sucesso = true;
Estipulante estipulante1 = estipulante;
Estipulante estipulante2 = await Task.Run<Estipulante>(() => {
Estipulante estipulante3;
bool flag;
while (num > 0)
{
List<RegistroLog> registroLogs = new List<RegistroLog>();
estipulante = estipulante1;
try
{
using (UnitOfWork commited = Instancia.Commited)
{
estipulante.set_IdEmpresa(Recursos.Empresa.get_Id());
flag = (estipulante.get_Id() == 0 ? false : true);
if (flag)
{
registroLogs.Add(base.CreateLog(estipulante.get_Id(), estipulante, 9));
}
estipulante = (estipulante.get_Id() == 0 ? commited.get_EstipulanteRepository().SaveOrUpdate(estipulante) : commited.get_EstipulanteRepository().Merge(estipulante));
if (!flag)
{
registroLogs.Add(base.CreateLog(estipulante.get_Id(), estipulante.GetValorOriginal(), 9, 0));
}
base.SaveLog(registroLogs, commited);
commited.Commit();
estipulante3 = estipulante;
}
}
catch (Exception exception)
{
num = base.Registrar(exception, 219, num, estipulante, true);
continue;
}
return estipulante3;
}
return estipulante1;
});
return estipulante2;
}
}
}
|