From 1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1 Mon Sep 17 00:00:00 2001 From: Lucas Faria Mendes Date: Mon, 30 Mar 2026 10:38:18 -0300 Subject: chore: location --- .../Servicos/Financeiro/CentroServico.cs | 92 ++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 Codemerx/Gestor.Application/Servicos/Financeiro/CentroServico.cs (limited to 'Codemerx/Gestor.Application/Servicos/Financeiro/CentroServico.cs') diff --git a/Codemerx/Gestor.Application/Servicos/Financeiro/CentroServico.cs b/Codemerx/Gestor.Application/Servicos/Financeiro/CentroServico.cs new file mode 100644 index 0000000..7d16a58 --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Financeiro/CentroServico.cs @@ -0,0 +1,92 @@ +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.Financeiro; +using Gestor.Model.Domain.Generic; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Runtime.CompilerServices; +using System.Threading.Tasks; + +namespace Gestor.Application.Servicos.Financeiro +{ + internal class CentroServico : BaseServico + { + public CentroServico() + { + } + + public async Task> BuscarCentros() + { + int num = 3; + List centros1 = await Task.Run>(() => { + List centros; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + centros = read.get_CentroRepository().Find(); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 153, num, null, true); + continue; + } + return centros; + } + return new List(); + }); + return centros1; + } + + public async Task Save(Centro centro) + { + int num = 3; + base.Sucesso = true; + Centro centro1 = centro; + Centro centro2 = await Task.Run(() => { + Centro centro3; + bool flag; + while (num > 0) + { + List registroLogs = new List(); + centro = centro1; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + flag = (centro.get_Id() == 0 ? false : true); + if (flag) + { + registroLogs.Add(base.CreateLog(centro.get_Id(), centro, 29)); + } + centro = (centro.get_Id() == 0 ? commited.get_CentroRepository().SaveOrUpdate(centro) : commited.get_CentroRepository().Merge(centro)); + if (!flag) + { + registroLogs.Add(base.CreateLog(centro.get_Id(), centro.GetValorOriginal(), 29, 0)); + } + base.SaveLog(registroLogs, commited); + commited.Commit(); + centro3 = centro; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 249, num, centro, true); + continue; + } + return centro3; + } + return centro1; + }); + return centro2; + } + } +} \ No newline at end of file -- cgit v1.2.3