diff options
Diffstat (limited to 'Decompiler/Gestor.Application.Servicos.Ferramentas/EstipulanteServico.cs')
| -rw-r--r-- | Decompiler/Gestor.Application.Servicos.Ferramentas/EstipulanteServico.cs | 125 |
1 files changed, 125 insertions, 0 deletions
diff --git a/Decompiler/Gestor.Application.Servicos.Ferramentas/EstipulanteServico.cs b/Decompiler/Gestor.Application.Servicos.Ferramentas/EstipulanteServico.cs new file mode 100644 index 0000000..126c369 --- /dev/null +++ b/Decompiler/Gestor.Application.Servicos.Ferramentas/EstipulanteServico.cs @@ -0,0 +1,125 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Gestor.Application.Helpers; +using Gestor.Application.Servicos.Generic; +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; + +namespace Gestor.Application.Servicos.Ferramentas; + +internal class EstipulanteServico : BaseServico +{ + internal async Task<Estipulante> BuscarEstipulantePorId(long id) + { + int tries = 3; + return await Task.Run((Func<Estipulante>)delegate + { + //IL_0059: Unknown result type (might be due to invalid IL or missing references) + //IL_005f: Expected O, but got Unknown + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return read.EstipulanteRepository.FindById(id); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)110, tries, id); + } + } + return new Estipulante(); + }); + } + + public async Task<Estipulante> Save(Estipulante estipulante) + { + int tries = 3; + base.Sucesso = true; + Estipulante estipulanteOriginal = estipulante; + return await Task.Run((Func<Estipulante>)delegate + { + while (tries > 0) + { + List<RegistroLog> list = new List<RegistroLog>(); + estipulante = estipulanteOriginal; + try + { + UnitOfWork commited = Instancia.Commited; + try + { + estipulante.IdEmpresa = ((DomainBase)Recursos.Empresa).Id; + bool num = ((DomainBase)estipulante).Id != 0L; + if (num) + { + list.Add(CreateLog(((DomainBase)estipulante).Id, estipulante, (TipoTela)9)); + } + estipulante = ((((DomainBase)estipulante).Id == 0L) ? commited.EstipulanteRepository.SaveOrUpdate(estipulante) : commited.EstipulanteRepository.Merge(estipulante)); + if (!num) + { + list.Add(CreateLog(((DomainBase)estipulante).Id, ((DomainBase)estipulante).GetValorOriginal(), (TipoTela)9, (TipoAcao)0)); + } + SaveLog(list, commited); + ((GenericUnitOfWork)commited).Commit(); + return estipulante; + } + finally + { + ((IDisposable)commited)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)219, tries, estipulante); + } + } + return estipulanteOriginal; + }); + } + + public async Task<bool> Delete(Estipulante estipulante) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + List<RegistroLog> list = new List<RegistroLog>(); + try + { + UnitOfWork commited = Instancia.Commited; + try + { + list.Add(CreateLog(((DomainBase)estipulante).Id, ((DomainBase)estipulante).GetValorOriginal(), (TipoTela)9, (TipoAcao)2)); + commited.EstipulanteRepository.Delete(((DomainBase)estipulante).Id); + SaveLog(list, commited); + ((GenericUnitOfWork)commited).Commit(); + return true; + } + finally + { + ((IDisposable)commited)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)220, tries, estipulante); + } + } + return false; + }); + } +} |