diff options
| author | Lucas Faria Mendes <lucas.fariamo08@gmail.com> | 2026-03-30 15:29:41 +0000 |
|---|---|---|
| committer | Lucas Faria Mendes <lucas.fariamo08@gmail.com> | 2026-03-30 15:29:41 +0000 |
| commit | 225aa1499e37faf9d38257caabbadc68d78b427e (patch) | |
| tree | 102bb7a40c58595348ae9d3c7076201759fe0720 /Decompiler/Gestor.Application.Servicos.Ferramentas/SocioServico.cs | |
| parent | 1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1 (diff) | |
| download | gestor-225aa1499e37faf9d38257caabbadc68d78b427e.tar.gz gestor-225aa1499e37faf9d38257caabbadc68d78b427e.zip | |
decompiler.com
Diffstat (limited to 'Decompiler/Gestor.Application.Servicos.Ferramentas/SocioServico.cs')
| -rw-r--r-- | Decompiler/Gestor.Application.Servicos.Ferramentas/SocioServico.cs | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/Decompiler/Gestor.Application.Servicos.Ferramentas/SocioServico.cs b/Decompiler/Gestor.Application.Servicos.Ferramentas/SocioServico.cs new file mode 100644 index 0000000..1b3a52c --- /dev/null +++ b/Decompiler/Gestor.Application.Servicos.Ferramentas/SocioServico.cs @@ -0,0 +1,94 @@ +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.Generic; + +namespace Gestor.Application.Servicos.Ferramentas; + +internal class SocioServico : BaseServico +{ + public async Task<Socio> Save(Socio socio) + { + int tries = 3; + base.Sucesso = true; + Socio socioOriginal = socio; + return await Task.Run((Func<Socio>)delegate + { + List<RegistroLog> list = new List<RegistroLog>(); + socio = socioOriginal; + while (tries > 0) + { + socio = socioOriginal; + try + { + UnitOfWork commited = Instancia.Commited; + try + { + bool num = ((DomainBase)socio).Id != 0L; + if (num) + { + list.Add(CreateLog(((DomainBase)socio).Id, socio, (TipoTela)19)); + } + socio = ((((DomainBase)socio).Id == 0L) ? commited.SocioRepository.SaveOrUpdate(socio) : commited.SocioRepository.Merge(socio)); + if (!num) + { + list.Add(CreateLog(((DomainBase)socio).Id, ((DomainBase)socio).GetValorOriginal(), (TipoTela)19, (TipoAcao)0)); + } + SaveLog(list, commited); + ((GenericUnitOfWork)commited).Commit(); + return socio; + } + finally + { + ((IDisposable)commited)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)235, tries, socio); + } + } + return socioOriginal; + }); + } + + public async Task<bool> Delete(Socio socio) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + List<RegistroLog> list = new List<RegistroLog>(); + try + { + UnitOfWork commited = Instancia.Commited; + try + { + list.Add(CreateLog(((DomainBase)socio).Id, ((DomainBase)socio).GetValorOriginal(), (TipoTela)19, (TipoAcao)2)); + commited.SocioRepository.Delete(((DomainBase)socio).Id); + SaveLog(list, commited); + ((GenericUnitOfWork)commited).Commit(); + return true; + } + finally + { + ((IDisposable)commited)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)236, tries, socio); + } + } + return false; + }); + } +} |