diff options
| author | Lucas Faria Mendes <lucas.fariamo08@gmail.com> | 2026-03-30 13:38:18 +0000 |
|---|---|---|
| committer | Lucas Faria Mendes <lucas.fariamo08@gmail.com> | 2026-03-30 13:38:18 +0000 |
| commit | 1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1 (patch) | |
| tree | e1c3b20ea08f0cf71122a1e73f0d395f8fd83874 /Codemerx/Gestor.Application/Servicos/Financeiro/CentroServico.cs | |
| parent | 674ca83ba9243a9e95a7568c797668dab6aee26a (diff) | |
| download | gestor-1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1.tar.gz gestor-1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1.zip | |
chore: location
Diffstat (limited to 'Codemerx/Gestor.Application/Servicos/Financeiro/CentroServico.cs')
| -rw-r--r-- | Codemerx/Gestor.Application/Servicos/Financeiro/CentroServico.cs | 92 |
1 files changed, 92 insertions, 0 deletions
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<List<Centro>> BuscarCentros()
+ {
+ int num = 3;
+ List<Centro> centros1 = await Task.Run<List<Centro>>(() => {
+ List<Centro> 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<Centro>();
+ });
+ return centros1;
+ }
+
+ public async Task<Centro> Save(Centro centro)
+ {
+ int num = 3;
+ base.Sucesso = true;
+ Centro centro1 = centro;
+ Centro centro2 = await Task.Run<Centro>(() => {
+ Centro centro3;
+ bool flag;
+ while (num > 0)
+ {
+ List<RegistroLog> registroLogs = new List<RegistroLog>();
+ 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 |