summaryrefslogtreecommitdiff
path: root/Decompiler/Gestor.Application.Servicos.Seguros.Itens/AeronauticoServico.cs
blob: 8e32f88ffb73a8b7b8e75e6f21f7667a6513cda5 (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
using System;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Threading.Tasks;
using Gestor.Application.Helpers;
using Gestor.Application.Servicos.Generic;
using Gestor.Application.ViewModels;
using Gestor.Infrastructure.UnitOfWork.Generic;
using Gestor.Infrastructure.UnitOfWork.Logic;
using Gestor.Model.API;
using Gestor.Model.Common;
using Gestor.Model.Domain.Common;
using Gestor.Model.Domain.Generic;
using Gestor.Model.Domain.Seguros;
using Newtonsoft.Json;

namespace Gestor.Application.Servicos.Seguros.Itens;

internal class AeronauticoServico : BaseServico
{
	public async Task<Aeronautico> Save(Aeronautico aeronautico)
	{
		return await Task.Run((Func<Aeronautico>)delegate
		{
			try
			{
				UnitOfWork commited = Instancia.Commited;
				try
				{
					aeronautico = ((((DomainBase)aeronautico).Id == 0L) ? commited.AeronauticoRepository.SaveOrUpdate(aeronautico) : commited.AeronauticoRepository.Merge(aeronautico));
					((GenericUnitOfWork)commited).Commit();
					return aeronautico;
				}
				finally
				{
					((IDisposable)commited)?.Dispose();
				}
			}
			catch (Exception)
			{
				return (Aeronautico)null;
			}
		});
	}

	public async Task<bool> Delete(Item item)
	{
		int tries = 3;
		return await Task.Run(delegate
		{
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Expected O, but got Unknown
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Expected O, but got Unknown
			while (tries > 0)
			{
				try
				{
					UnitOfWork commited = Instancia.Commited;
					try
					{
						if (item.Aeronautico != null && ((DomainBase)item.Aeronautico).Id > 0)
						{
							commited.AeronauticoRepository.Delete(((DomainBase)item.Aeronautico).Id);
						}
						commited.CoberturaRepository.DeletebyItem(((DomainBase)item).Id);
						commited.ControleSinistroRepository.DeleteByItem(((DomainBase)item).Id);
						commited.ItemRepository.Delete(((DomainBase)item).Id);
						DateTime networkTime = Funcoes.GetNetworkTime();
						IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
						RegistroLog val = new RegistroLog
						{
							Acao = (TipoAcao)2,
							Usuario = Recursos.Usuario,
							DataHora = networkTime,
							Descricao = JsonConvert.SerializeObject((object)item, new JsonSerializerSettings
							{
								ReferenceLoopHandling = (ReferenceLoopHandling)1
							})
						};
						Aeronautico aeronautico = item.Aeronautico;
						val.EntidadeId = ((aeronautico != null) ? ((DomainBase)aeronautico).Id : 0);
						val.Tela = (TipoTela)3;
						val.Versao = LoginViewModel.VersaoAtual;
						val.NomeMaquina = Environment.MachineName;
						val.UsuarioMaquina = Environment.UserName;
						val.Ip = hostEntry.AddressList.FirstOrDefault((IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork)?.ToString();
						RegistroLog keyValues = val;
						SaveLog(keyValues, commited);
						((GenericUnitOfWork)commited).Commit();
						return true;
					}
					finally
					{
						((IDisposable)commited)?.Dispose();
					}
				}
				catch (Exception e)
				{
					tries = Registrar(e, (TipoErro)203, tries, item);
				}
			}
			return false;
		});
	}
}