diff options
| author | Lucas Faria Mendes <lucas.fariamo08@gmail.com> | 2026-03-30 15:29:41 +0000 |
|---|---|---|
| committer | Lucas Faria Mendes <lucas.fariamo08@gmail.com> | 2026-03-30 15:29:41 +0000 |
| commit | 225aa1499e37faf9d38257caabbadc68d78b427e (patch) | |
| tree | 102bb7a40c58595348ae9d3c7076201759fe0720 /Decompiler/Gestor.Application.Servicos/VendedorUsuarioServico.cs | |
| parent | 1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1 (diff) | |
| download | gestor-225aa1499e37faf9d38257caabbadc68d78b427e.tar.gz gestor-225aa1499e37faf9d38257caabbadc68d78b427e.zip | |
decompiler.com
Diffstat (limited to 'Decompiler/Gestor.Application.Servicos/VendedorUsuarioServico.cs')
| -rw-r--r-- | Decompiler/Gestor.Application.Servicos/VendedorUsuarioServico.cs | 175 |
1 files changed, 175 insertions, 0 deletions
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<List<VendedorUsuario>> 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<VendedorUsuario>(); + }); + } + + public async Task<List<VendedorUsuario>> SaveOrUpdate(List<VendedorUsuario> vinculo) + { + int tries = 3; + base.Sucesso = true; + List<VendedorUsuario> 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<bool> Delete(List<VendedorUsuario> 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<bool> 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<bool> 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; + }); + } +} |