From 674ca83ba9243a9e95a7568c797668dab6aee26a Mon Sep 17 00:00:00 2001 From: Lucas Faria Mendes Date: Mon, 30 Mar 2026 10:35:25 -0300 Subject: feat: upload files --- .../Servicos/VendedorUsuarioServico.cs | 160 +++++++++++++++++++++ 1 file changed, 160 insertions(+) create mode 100644 Gestor.Application/Servicos/VendedorUsuarioServico.cs (limited to 'Gestor.Application/Servicos/VendedorUsuarioServico.cs') diff --git a/Gestor.Application/Servicos/VendedorUsuarioServico.cs b/Gestor.Application/Servicos/VendedorUsuarioServico.cs new file mode 100644 index 0000000..4804dac --- /dev/null +++ b/Gestor.Application/Servicos/VendedorUsuarioServico.cs @@ -0,0 +1,160 @@ +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.Generic; +using Gestor.Model.Domain.Seguros; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Threading.Tasks; + +namespace Gestor.Application.Servicos +{ + public class VendedorUsuarioServico : BaseServico + { + public VendedorUsuarioServico() + { + } + + public async Task Delete(List vinculo) + { + int num = 3; + bool flag1 = await Task.Run(() => { + bool flag; + while (num > 0) + { + try + { + using (UnitOfWork commited = Instancia.Commited) + { + vinculo.ForEach((VendedorUsuario x) => commited.get_VendedorUsuarioRepository().Delete(x.get_Id())); + commited.Commit(); + } + flag = true; + } + catch (Exception exception) + { + num = base.Registrar(exception, 272, num, vinculo, true); + continue; + } + return flag; + } + return false; + }); + return flag1; + } + + public async Task> FindByVinculo(Usuario usuario) + { + int num = 3; + List vendedorUsuarios = await Task.Run>(() => { + List list; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + list = read.get_VendedorUsuarioRepository().FindByVinculo(usuario.get_Id()).ToList(); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 106, num, usuario, true); + continue; + } + return list; + } + return new List(); + }); + return vendedorUsuarios; + } + + public async Task FindVinculo(Vendedor vendedor) + { + int num = 3; + bool flag1 = await Task.Run(() => { + bool flag; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + flag = read.get_VendedorUsuarioRepository().Exist(vendedor.get_Id()); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 271, num, vendedor, true); + continue; + } + return flag; + } + return false; + }); + return flag1; + } + + public async Task FindVinculoByUsuario(long idusuario) + { + int num = 3; + bool flag1 = await Task.Run(() => { + bool flag; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + flag = read.get_VendedorUsuarioRepository().ExistVinculoUsuario(idusuario); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 106, num, null, true); + continue; + } + return flag; + } + return false; + }); + return flag1; + } + + public async Task> SaveOrUpdate(List vinculo) + { + int num = 3; + base.Sucesso = true; + List vendedorUsuarios1 = vinculo; + List vendedorUsuarios2 = await Task.Run>(() => { + List vendedorUsuarios; + while (num > 0) + { + vinculo = vendedorUsuarios1; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + vinculo.ForEach((VendedorUsuario x) => commited.get_VendedorUsuarioRepository().SaveOrUpdate(x)); + commited.Commit(); + } + vendedorUsuarios = vinculo; + } + catch (Exception exception) + { + num = base.Registrar(exception, 271, num, vinculo, true); + continue; + } + return vendedorUsuarios; + } + return vendedorUsuarios1; + }); + return vendedorUsuarios2; + } + } +} \ No newline at end of file -- cgit v1.2.3