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/Ferramentas/EstipulanteServico.cs | 124 +++++++++++++++++++++ 1 file changed, 124 insertions(+) create mode 100644 Gestor.Application/Servicos/Ferramentas/EstipulanteServico.cs (limited to 'Gestor.Application/Servicos/Ferramentas/EstipulanteServico.cs') diff --git a/Gestor.Application/Servicos/Ferramentas/EstipulanteServico.cs b/Gestor.Application/Servicos/Ferramentas/EstipulanteServico.cs new file mode 100644 index 0000000..413a361 --- /dev/null +++ b/Gestor.Application/Servicos/Ferramentas/EstipulanteServico.cs @@ -0,0 +1,124 @@ +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 Gestor.Model.Domain.Seguros; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Runtime.CompilerServices; +using System.Threading.Tasks; + +namespace Gestor.Application.Servicos.Ferramentas +{ + internal class EstipulanteServico : BaseServico + { + public EstipulanteServico() + { + } + + internal async Task BuscarEstipulantePorId(long id) + { + int num = 3; + Estipulante estipulante1 = await Task.Run(() => { + Estipulante estipulante; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + estipulante = read.get_EstipulanteRepository().FindById(id); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 110, num, id, true); + continue; + } + return estipulante; + } + return new Estipulante(); + }); + return estipulante1; + } + + public async Task Delete(Estipulante estipulante) + { + int num = 3; + bool flag1 = await Task.Run(() => { + bool flag; + while (num > 0) + { + List registroLogs = new List(); + try + { + using (UnitOfWork commited = Instancia.Commited) + { + registroLogs.Add(base.CreateLog(estipulante.get_Id(), estipulante.GetValorOriginal(), 9, 2)); + commited.get_EstipulanteRepository().Delete(estipulante.get_Id()); + base.SaveLog(registroLogs, commited); + commited.Commit(); + flag = true; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 220, num, estipulante, true); + continue; + } + return flag; + } + return false; + }); + return flag1; + } + + public async Task Save(Estipulante estipulante) + { + int num = 3; + base.Sucesso = true; + Estipulante estipulante1 = estipulante; + Estipulante estipulante2 = await Task.Run(() => { + Estipulante estipulante3; + bool flag; + while (num > 0) + { + List registroLogs = new List(); + estipulante = estipulante1; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + estipulante.set_IdEmpresa(Recursos.Empresa.get_Id()); + flag = (estipulante.get_Id() == 0 ? false : true); + if (flag) + { + registroLogs.Add(base.CreateLog(estipulante.get_Id(), estipulante, 9)); + } + estipulante = (estipulante.get_Id() == 0 ? commited.get_EstipulanteRepository().SaveOrUpdate(estipulante) : commited.get_EstipulanteRepository().Merge(estipulante)); + if (!flag) + { + registroLogs.Add(base.CreateLog(estipulante.get_Id(), estipulante.GetValorOriginal(), 9, 0)); + } + base.SaveLog(registroLogs, commited); + commited.Commit(); + estipulante3 = estipulante; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 219, num, estipulante, true); + continue; + } + return estipulante3; + } + return estipulante1; + }); + return estipulante2; + } + } +} \ No newline at end of file -- cgit v1.2.3