diff options
Diffstat (limited to 'Gestor.Application/Servicos/Seguros/ProfissaoServico.cs')
| -rw-r--r-- | Gestor.Application/Servicos/Seguros/ProfissaoServico.cs | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/Gestor.Application/Servicos/Seguros/ProfissaoServico.cs b/Gestor.Application/Servicos/Seguros/ProfissaoServico.cs new file mode 100644 index 0000000..f528fcb --- /dev/null +++ b/Gestor.Application/Servicos/Seguros/ProfissaoServico.cs @@ -0,0 +1,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;
+ }
+ }
+}
\ No newline at end of file |