diff options
Diffstat (limited to 'Decompiler/Gestor.Application.Servicos.Financeiro/FornecedorServico.cs')
| -rw-r--r-- | Decompiler/Gestor.Application.Servicos.Financeiro/FornecedorServico.cs | 127 |
1 files changed, 127 insertions, 0 deletions
diff --git a/Decompiler/Gestor.Application.Servicos.Financeiro/FornecedorServico.cs b/Decompiler/Gestor.Application.Servicos.Financeiro/FornecedorServico.cs new file mode 100644 index 0000000..f26bc53 --- /dev/null +++ b/Decompiler/Gestor.Application.Servicos.Financeiro/FornecedorServico.cs @@ -0,0 +1,127 @@ +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; + +public class FornecedorServico : BaseServico +{ + public async Task<Fornecedor> Save(Fornecedor fornecedor) + { + int tries = 3; + base.Sucesso = true; + Fornecedor fornecedorOriginal = fornecedor; + return await Task.Run((Func<Fornecedor>)delegate + { + //IL_002e: Unknown result type (might be due to invalid IL or missing references) + //IL_002f: Unknown result type (might be due to invalid IL or missing references) + //IL_0031: Invalid comparison between Unknown and I4 + //IL_0058: Unknown result type (might be due to invalid IL or missing references) + //IL_0084: Unknown result type (might be due to invalid IL or missing references) + while (tries > 0) + { + List<RegistroLog> list = new List<RegistroLog>(); + fornecedor = fornecedorOriginal; + try + { + UnitOfWork commited = Instancia.Commited; + try + { + TipoAcao val = (TipoAcao)(fornecedor.Id != 0L); + if ((int)val == 1) + { + list.Add(CreateLog(fornecedor.Id, fornecedor, (TipoTela)24)); + } + fornecedor = (((int)val == 0) ? commited.FornecedorRepository.SaveOrUpdate(fornecedor) : commited.FornecedorRepository.Merge(fornecedor)); + if ((int)val == 0) + { + list.Add(CreateLog(fornecedor.Id, ((DomainBase)fornecedor).GetValorOriginal(), (TipoTela)24, (TipoAcao)0)); + } + SaveLog(list, commited); + ((GenericUnitOfWork)commited).Commit(); + return fornecedor; + } + finally + { + ((IDisposable)commited)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)243, tries, fornecedor); + } + } + return fornecedorOriginal; + }); + } + + public async Task<bool> Delete(Fornecedor fornecedor) + { + 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(fornecedor.Id, ((DomainBase)fornecedor).GetValorOriginal(), (TipoTela)24, (TipoAcao)2)); + commited.FornecedorRepository.Delete(fornecedor.Id); + SaveLog(list, commited); + ((GenericUnitOfWork)commited).Commit(); + return true; + } + finally + { + ((IDisposable)commited)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)244, tries, fornecedor); + } + } + return false; + }); + } + + public async Task<List<Fornecedor>> BuscarFornecedores() + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return read.FornecedorRepository.Find(); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)166, tries); + } + } + return new List<Fornecedor>(); + }); + } +} |