From 225aa1499e37faf9d38257caabbadc68d78b427e Mon Sep 17 00:00:00 2001 From: Lucas Faria Mendes Date: Mon, 30 Mar 2026 12:29:41 -0300 Subject: decompiler.com --- .../VendedorUsuarioServico.cs | 175 +++++++++++++++++++++ 1 file changed, 175 insertions(+) create mode 100644 Decompiler/Gestor.Application.Servicos/VendedorUsuarioServico.cs (limited to 'Decompiler/Gestor.Application.Servicos/VendedorUsuarioServico.cs') diff --git a/Decompiler/Gestor.Application.Servicos/VendedorUsuarioServico.cs b/Decompiler/Gestor.Application.Servicos/VendedorUsuarioServico.cs new file mode 100644 index 0000000..b73e0aa --- /dev/null +++ b/Decompiler/Gestor.Application.Servicos/VendedorUsuarioServico.cs @@ -0,0 +1,175 @@ +using System; +using System.Collections.Generic; +using System.Linq; +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.Domain.Generic; +using Gestor.Model.Domain.Seguros; + +namespace Gestor.Application.Servicos; + +public class VendedorUsuarioServico : BaseServico +{ + public async Task> FindByVinculo(Usuario usuario) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return read.VendedorUsuarioRepository.FindByVinculo(((DomainBase)usuario).Id).ToList(); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)106, tries, usuario); + } + } + return new List(); + }); + } + + public async Task> SaveOrUpdate(List vinculo) + { + int tries = 3; + base.Sucesso = true; + List vinculoOriginal = vinculo; + return await Task.Run(delegate + { + while (tries > 0) + { + vinculo = vinculoOriginal; + try + { + UnitOfWork unitOfWork = Instancia.Commited; + try + { + vinculo.ForEach(delegate(VendedorUsuario x) + { + unitOfWork.VendedorUsuarioRepository.SaveOrUpdate(x); + }); + ((GenericUnitOfWork)unitOfWork).Commit(); + } + finally + { + if (unitOfWork != null) + { + ((IDisposable)unitOfWork).Dispose(); + } + } + return vinculo; + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)271, tries, vinculo); + } + } + return vinculoOriginal; + }); + } + + public async Task Delete(List vinculo) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork unitOfWork = Instancia.Commited; + try + { + vinculo.ForEach(delegate(VendedorUsuario x) + { + unitOfWork.VendedorUsuarioRepository.Delete(((DomainBase)x).Id); + }); + ((GenericUnitOfWork)unitOfWork).Commit(); + } + finally + { + if (unitOfWork != null) + { + ((IDisposable)unitOfWork).Dispose(); + } + } + return true; + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)272, tries, vinculo); + } + } + return false; + }); + } + + public async Task FindVinculo(Vendedor vendedor) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return read.VendedorUsuarioRepository.Exist(((DomainBase)vendedor).Id); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)271, tries, vendedor); + } + } + return false; + }); + } + + public async Task FindVinculoByUsuario(long idusuario) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return read.VendedorUsuarioRepository.ExistVinculoUsuario(idusuario); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)106, tries); + } + } + return false; + }); + } +} -- cgit v1.2.3