summaryrefslogtreecommitdiff
path: root/Gestor.Application/Servicos/Seguros/ProfissaoServico.cs
blob: f528fcbabcee1e5c499c2ec9e6ada729755fbd5b (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
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 System;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;

namespace Gestor.Application.Servicos.Seguros
{
	internal class ProfissaoServico : BaseServico
	{
		public ProfissaoServico()
		{
		}

		public async Task<long> FindLastId()
		{
			int num1 = 3;
			long num2 = await Task.Run<long>(() => {
				long num;
				while (num1 > 0)
				{
					try
					{
						using (UnitOfWork read = Instancia.Read)
						{
							num = read.get_ProfissaoRepository().FindLastId();
						}
					}
					catch (Exception exception)
					{
						num1 = base.Registrar(exception, 17, num1, null, true);
						continue;
					}
					return num;
				}
				return (long)0;
			});
			return num2;
		}

		public async Task<Profissao> Save(Profissao profissao)
		{
			int num = 3;
			base.Sucesso = true;
			Profissao profissao1 = profissao;
			Profissao profissao2 = await Task.Run<Profissao>(() => {
				Profissao profissao3;
				while (num > 0)
				{
					profissao = profissao1;
					try
					{
						using (UnitOfWork commited = Instancia.Commited)
						{
							profissao = (profissao.get_Id() == (long)0 ? commited.get_ProfissaoRepository().SaveOrUpdate(profissao) : commited.get_ProfissaoRepository().Merge(profissao));
							commited.Commit();
							profissao3 = profissao;
						}
					}
					catch (Exception exception)
					{
						num = base.Registrar(exception, 214, num, profissao, true);
						continue;
					}
					return profissao3;
				}
				return profissao1;
			});
			return profissao2;
		}
	}
}