summaryrefslogtreecommitdiff
path: root/Decompiler/Gestor.Application.Servicos.Financeiro/CentroServico.cs
diff options
context:
space:
mode:
authorLucas Faria Mendes <lucas.fariamo08@gmail.com>2026-03-30 15:29:41 +0000
committerLucas Faria Mendes <lucas.fariamo08@gmail.com>2026-03-30 15:29:41 +0000
commit225aa1499e37faf9d38257caabbadc68d78b427e (patch)
tree102bb7a40c58595348ae9d3c7076201759fe0720 /Decompiler/Gestor.Application.Servicos.Financeiro/CentroServico.cs
parent1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1 (diff)
downloadgestor-225aa1499e37faf9d38257caabbadc68d78b427e.tar.gz
gestor-225aa1499e37faf9d38257caabbadc68d78b427e.zip
decompiler.com
Diffstat (limited to 'Decompiler/Gestor.Application.Servicos.Financeiro/CentroServico.cs')
-rw-r--r--Decompiler/Gestor.Application.Servicos.Financeiro/CentroServico.cs89
1 files changed, 89 insertions, 0 deletions
diff --git a/Decompiler/Gestor.Application.Servicos.Financeiro/CentroServico.cs b/Decompiler/Gestor.Application.Servicos.Financeiro/CentroServico.cs
new file mode 100644
index 0000000..0323595
--- /dev/null
+++ b/Decompiler/Gestor.Application.Servicos.Financeiro/CentroServico.cs
@@ -0,0 +1,89 @@
+using System;
+using System.Collections.Generic;
+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.Common;
+using Gestor.Model.Domain.Common;
+using Gestor.Model.Domain.Financeiro;
+using Gestor.Model.Domain.Generic;
+
+namespace Gestor.Application.Servicos.Financeiro;
+
+internal class CentroServico : BaseServico
+{
+ public async Task<Centro> Save(Centro centro)
+ {
+ int tries = 3;
+ base.Sucesso = true;
+ Centro centroOriginal = centro;
+ return await Task.Run((Func<Centro>)delegate
+ {
+ while (tries > 0)
+ {
+ List<RegistroLog> list = new List<RegistroLog>();
+ centro = centroOriginal;
+ try
+ {
+ UnitOfWork commited = Instancia.Commited;
+ try
+ {
+ bool num = ((DomainBase)centro).Id != 0L;
+ if (num)
+ {
+ list.Add(CreateLog(((DomainBase)centro).Id, centro, (TipoTela)29));
+ }
+ centro = ((((DomainBase)centro).Id == 0L) ? commited.CentroRepository.SaveOrUpdate(centro) : commited.CentroRepository.Merge(centro));
+ if (!num)
+ {
+ list.Add(CreateLog(((DomainBase)centro).Id, ((DomainBase)centro).GetValorOriginal(), (TipoTela)29, (TipoAcao)0));
+ }
+ SaveLog(list, commited);
+ ((GenericUnitOfWork)commited).Commit();
+ return centro;
+ }
+ finally
+ {
+ ((IDisposable)commited)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)249, tries, centro);
+ }
+ }
+ return centroOriginal;
+ });
+ }
+
+ public async Task<List<Centro>> BuscarCentros()
+ {
+ int tries = 3;
+ return await Task.Run(delegate
+ {
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork read = Instancia.Read;
+ try
+ {
+ return read.CentroRepository.Find();
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)153, tries);
+ }
+ }
+ return new List<Centro>();
+ });
+ }
+}