diff options
Diffstat (limited to 'Decompiler/Gestor.Application.Servicos.Ferramentas/VendedorServico.cs')
| -rw-r--r-- | Decompiler/Gestor.Application.Servicos.Ferramentas/VendedorServico.cs | 825 |
1 files changed, 825 insertions, 0 deletions
diff --git a/Decompiler/Gestor.Application.Servicos.Ferramentas/VendedorServico.cs b/Decompiler/Gestor.Application.Servicos.Ferramentas/VendedorServico.cs new file mode 100644 index 0000000..b9327fb --- /dev/null +++ b/Decompiler/Gestor.Application.Servicos.Ferramentas/VendedorServico.cs @@ -0,0 +1,825 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Net; +using System.Net.Sockets; +using System.Threading.Tasks; +using Gestor.Application.Helpers; +using Gestor.Application.Servicos.Generic; +using Gestor.Application.ViewModels; +using Gestor.Common.Validation; +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.Ferramentas; +using Gestor.Model.Domain.Generic; +using Gestor.Model.Domain.Relatorios; +using Gestor.Model.Domain.Seguros; +using Newtonsoft.Json; + +namespace Gestor.Application.Servicos.Ferramentas; + +public class VendedorServico : BaseServico +{ + internal async Task<List<Vendedor>> BuscarVendedoresAtivosAsync() + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return new List<Vendedor>(from x in read.VendedorRepository.Find(true, (Recursos.Usuario.IdEmpresa == 1) ? 0 : Recursos.Usuario.IdEmpresa) + orderby x.Nome + select x); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)135, tries); + } + } + return new List<Vendedor>(); + }); + } + + public async Task<List<ManutencaoPagamentos>> BuscarPagos(Filtros filtro) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return read.VendedorParcelaRepository.FindByDate(filtro).ToList(); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)80, tries); + } + } + return new List<ManutencaoPagamentos>(); + }); + } + + public async Task<VendedorParcela> BuscarVendedorParcelaCompleto(long id) + { + int tries = 3; + return await Task.Run((Func<VendedorParcela>)delegate + { + //IL_004f: Unknown result type (might be due to invalid IL or missing references) + //IL_0055: Expected O, but got Unknown + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return read.VendedorParcelaRepository.FindById(id); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)81, tries); + } + } + return new VendedorParcela(); + }); + } + + public async Task<List<VendedorParcela>> BuscaRepasse(long id) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return (from x in read.VendedorParcelaRepository.FindByDocumentId(id) + orderby ((DomainBase)x.TipoVendedor).Id + select x).ToList(); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)136, tries, id); + } + } + return new List<VendedorParcela>(); + }); + } + + public async Task<List<VendedorParcela>> BuscaRepasseParcela(long id) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return read.VendedorParcelaRepository.FindByParcela(id).OrderBy(delegate(VendedorParcela x) + { + TipoVendedor tipoVendedor = x.TipoVendedor; + return (tipoVendedor == null) ? null : new long?(((DomainBase)tipoVendedor).Id); + }).ToList(); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)137, tries, id); + } + } + return new List<VendedorParcela>(); + }); + } + + internal async Task<ObservableCollection<VendedorTelefone>> BuscarTelefonesAsync(long id) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return new ObservableCollection<VendedorTelefone>(from x in read.VendedorTelefoneRepository.FindByVendedorId(id) + orderby x.Nome + select x); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)138, tries, id); + } + } + return new ObservableCollection<VendedorTelefone>(); + }); + } + + internal async Task<Vendedor> BuscarVendedorPorId(long id) + { + int tries = 3; + return await Task.Run((Func<Vendedor>)delegate + { + //IL_005c: Unknown result type (might be due to invalid IL or missing references) + //IL_0062: Expected O, but got Unknown + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return read.VendedorRepository.FindById(id); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)139, tries, id); + } + } + return new Vendedor(); + }); + } + + public async Task<List<Repasse>> BuscaRepasses() + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return read.RepasseRepository.DefaultSelect(0L); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)142, tries); + } + } + return new List<Repasse>(); + }); + } + + public async Task<Vendedor> Save(Vendedor vendedor, Repasse repasse) + { + int tries = 3; + base.Sucesso = true; + Vendedor vendedorOriginal = vendedor; + return await Task.Run((Func<Vendedor>)delegate + { + while (tries > 0) + { + vendedor = vendedorOriginal; + try + { + UnitOfWork commited = Instancia.Commited; + try + { + vendedor.IdEmpresa = ((vendedor.IdEmpresa == 0L) ? ((DomainBase)Recursos.Empresa).Id : vendedor.IdEmpresa); + vendedor = commited.VendedorRepository.SaveOrUpdate(vendedor); + repasse.Vendedor = vendedor; + repasse = commited.RepasseRepository.SaveOrUpdate(repasse); + ((GenericUnitOfWork)commited).Commit(); + return vendedor; + } + finally + { + ((IDisposable)commited)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)241, tries, new { vendedor, repasse }); + } + } + return vendedorOriginal; + }); + } + + public async Task<VinculoRepasse> Save(VinculoRepasse vinculo) + { + int tries = 3; + base.Sucesso = true; + DateTime now = Funcoes.GetNetworkTime(); + return await Task.Run((Func<VinculoRepasse>)delegate + { + //IL_001e: Unknown result type (might be due to invalid IL or missing references) + //IL_001f: Unknown result type (might be due to invalid IL or missing references) + //IL_0048: Unknown result type (might be due to invalid IL or missing references) + //IL_004d: Unknown result type (might be due to invalid IL or missing references) + //IL_004e: Unknown result type (might be due to invalid IL or missing references) + //IL_0054: Unknown result type (might be due to invalid IL or missing references) + //IL_005f: Unknown result type (might be due to invalid IL or missing references) + //IL_006b: Unknown result type (might be due to invalid IL or missing references) + //IL_006d: Unknown result type (might be due to invalid IL or missing references) + //IL_0072: Unknown result type (might be due to invalid IL or missing references) + //IL_007e: Expected O, but got Unknown + //IL_0083: Unknown result type (might be due to invalid IL or missing references) + //IL_008f: Unknown result type (might be due to invalid IL or missing references) + //IL_0097: Unknown result type (might be due to invalid IL or missing references) + //IL_00a2: Unknown result type (might be due to invalid IL or missing references) + //IL_00ad: Unknown result type (might be due to invalid IL or missing references) + //IL_00b8: Unknown result type (might be due to invalid IL or missing references) + //IL_00f6: Expected O, but got Unknown + while (tries > 0) + { + VinculoRepasse val = vinculo; + try + { + UnitOfWork commited = Instancia.Commited; + try + { + TipoAcao val2 = (TipoAcao)(((DomainBase)val).Id != 0L); + val = (((int)val2 == 0) ? commited.RepasseRepository.SaveOrUpdate(val) : commited.RepasseRepository.Merge(val)); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + RegistroLog keyValues = new RegistroLog + { + Acao = val2, + Usuario = Recursos.Usuario, + DataHora = now, + Descricao = JsonConvert.SerializeObject((object)val, new JsonSerializerSettings + { + ReferenceLoopHandling = (ReferenceLoopHandling)1 + }), + EntidadeId = ((DomainBase)val).Id, + Tela = (TipoTela)53, + Versao = LoginViewModel.VersaoAtual, + NomeMaquina = Environment.MachineName, + UsuarioMaquina = Environment.UserName, + Ip = hostEntry.AddressList.FirstOrDefault((IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork)?.ToString() + }; + SaveLog(keyValues, commited); + ((GenericUnitOfWork)commited).Commit(); + return val; + } + finally + { + ((IDisposable)commited)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)311, tries, vinculo); + } + } + return vinculo; + }); + } + + public async Task<bool> Delete(VinculoRepasse vinculo) + { + int tries = 3; + base.Sucesso = true; + DateTime now = Funcoes.GetNetworkTime(); + return await Task.Run(delegate + { + //IL_002d: Unknown result type (might be due to invalid IL or missing references) + //IL_0032: Unknown result type (might be due to invalid IL or missing references) + //IL_0039: Unknown result type (might be due to invalid IL or missing references) + //IL_0044: Unknown result type (might be due to invalid IL or missing references) + //IL_0050: Unknown result type (might be due to invalid IL or missing references) + //IL_0057: Unknown result type (might be due to invalid IL or missing references) + //IL_005c: Unknown result type (might be due to invalid IL or missing references) + //IL_0068: Expected O, but got Unknown + //IL_006d: Unknown result type (might be due to invalid IL or missing references) + //IL_007e: Unknown result type (might be due to invalid IL or missing references) + //IL_0086: Unknown result type (might be due to invalid IL or missing references) + //IL_0091: Unknown result type (might be due to invalid IL or missing references) + //IL_009c: Unknown result type (might be due to invalid IL or missing references) + //IL_00a7: Unknown result type (might be due to invalid IL or missing references) + //IL_00e4: Expected O, but got Unknown + while (tries > 0) + { + try + { + UnitOfWork commited = Instancia.Commited; + try + { + commited.RepasseRepository.DeleteVinculo(((DomainBase)vinculo).Id); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + RegistroLog keyValues = new RegistroLog + { + Acao = (TipoAcao)2, + Usuario = Recursos.Usuario, + DataHora = now, + Descricao = JsonConvert.SerializeObject((object)vinculo, new JsonSerializerSettings + { + ReferenceLoopHandling = (ReferenceLoopHandling)1 + }), + EntidadeId = ((DomainBase)vinculo).Id, + Tela = (TipoTela)53, + Versao = LoginViewModel.VersaoAtual, + NomeMaquina = Environment.MachineName, + UsuarioMaquina = Environment.UserName, + Ip = hostEntry.AddressList.FirstOrDefault((IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork)?.ToString() + }; + SaveLog(keyValues, commited); + ((GenericUnitOfWork)commited).Commit(); + return true; + } + finally + { + ((IDisposable)commited)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)311, tries, vinculo); + } + } + return false; + }); + } + + public async Task<Vendedor> Save(Vendedor vendedor, List<Repasse> repasses) + { + int tries = 3; + base.Sucesso = true; + DateTime now = Funcoes.GetNetworkTime(); + Vendedor vendedorOriginal = vendedor; + return await Task.Run((Func<Vendedor>)delegate + { + //IL_00c9: Unknown result type (might be due to invalid IL or missing references) + //IL_0228: Unknown result type (might be due to invalid IL or missing references) + //IL_022d: Unknown result type (might be due to invalid IL or missing references) + //IL_022e: Unknown result type (might be due to invalid IL or missing references) + //IL_0234: Unknown result type (might be due to invalid IL or missing references) + //IL_023f: Unknown result type (might be due to invalid IL or missing references) + //IL_024b: Unknown result type (might be due to invalid IL or missing references) + //IL_0252: Unknown result type (might be due to invalid IL or missing references) + //IL_0257: Unknown result type (might be due to invalid IL or missing references) + //IL_0263: Expected O, but got Unknown + //IL_0268: Unknown result type (might be due to invalid IL or missing references) + //IL_0279: Unknown result type (might be due to invalid IL or missing references) + //IL_0281: Unknown result type (might be due to invalid IL or missing references) + //IL_028c: Unknown result type (might be due to invalid IL or missing references) + //IL_0297: Unknown result type (might be due to invalid IL or missing references) + //IL_02a2: Unknown result type (might be due to invalid IL or missing references) + //IL_02e0: Expected O, but got Unknown + //IL_0309: Unknown result type (might be due to invalid IL or missing references) + //IL_030e: Unknown result type (might be due to invalid IL or missing references) + //IL_030f: Unknown result type (might be due to invalid IL or missing references) + //IL_0315: Unknown result type (might be due to invalid IL or missing references) + //IL_0320: Unknown result type (might be due to invalid IL or missing references) + //IL_032c: Unknown result type (might be due to invalid IL or missing references) + //IL_032f: Unknown result type (might be due to invalid IL or missing references) + //IL_0334: Unknown result type (might be due to invalid IL or missing references) + //IL_0340: Expected O, but got Unknown + //IL_0345: Unknown result type (might be due to invalid IL or missing references) + //IL_0352: Unknown result type (might be due to invalid IL or missing references) + //IL_035a: Unknown result type (might be due to invalid IL or missing references) + //IL_0365: Unknown result type (might be due to invalid IL or missing references) + //IL_0370: Unknown result type (might be due to invalid IL or missing references) + //IL_037b: Unknown result type (might be due to invalid IL or missing references) + //IL_03b9: Expected O, but got Unknown + while (tries > 0) + { + vendedor = vendedorOriginal; + try + { + List<VendedorTelefone> list = vendedor.Telefones; + UnitOfWork commited = Instancia.Commited; + try + { + foreach (Repasse item in repasses.Where(delegate(Repasse r) + { + Ramo ramo = r.Ramo; + return ramo != null && ((DomainBase)ramo).Id == 0; + })) + { + item.Ramo = null; + } + bool num = ((DomainBase)vendedor).Id == 0; + vendedor.IdEmpresa = ((vendedor.IdEmpresa == 0L) ? ((DomainBase)Recursos.Empresa).Id : vendedor.IdEmpresa); + TipoAcao acao = (TipoAcao)(((DomainBase)vendedor).Id != 0L); + if (num) + { + vendedor = commited.VendedorRepository.SaveOrUpdate(vendedor); + if (list != null) + { + list = commited.VendedorTelefoneRepository.Inserir(list, vendedor); + } + if (repasses != null && repasses.Count > 0) + { + foreach (Repasse repass in repasses) + { + repass.Vendedor = vendedor; + commited.RepasseRepository.SaveOrUpdate(repass); + } + } + } + else + { + vendedor = commited.VendedorRepository.Merge(vendedor); + if (list != null) + { + list = commited.VendedorTelefoneRepository.Merge(list, vendedor); + } + if (repasses != null && repasses.Count > 0) + { + foreach (Repasse repass2 in repasses) + { + if (((DomainBase)repass2).Id == 0L) + { + commited.RepasseRepository.SaveOrUpdate(repass2); + } + else + { + commited.RepasseRepository.Merge(repass2); + } + } + } + } + vendedor.Telefones = list; + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + if (((DomainBase)Recursos.Usuario).Id != 0L) + { + RegistroLog keyValues = new RegistroLog + { + Acao = acao, + Usuario = Recursos.Usuario, + DataHora = now, + Descricao = JsonConvert.SerializeObject((object)vendedor, new JsonSerializerSettings + { + ReferenceLoopHandling = (ReferenceLoopHandling)1 + }), + EntidadeId = ((DomainBase)vendedor).Id, + Tela = (TipoTela)15, + Versao = LoginViewModel.VersaoAtual, + NomeMaquina = Environment.MachineName, + UsuarioMaquina = Environment.UserName, + Ip = hostEntry.AddressList.FirstOrDefault((IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork)?.ToString() + }; + SaveLog(keyValues, commited); + foreach (Repasse repass3 in repasses) + { + keyValues = new RegistroLog + { + Acao = acao, + Usuario = Recursos.Usuario, + DataHora = now, + Descricao = JsonConvert.SerializeObject((object)repass3, new JsonSerializerSettings + { + ReferenceLoopHandling = (ReferenceLoopHandling)1 + }), + EntidadeId = ((DomainBase)repass3).Id, + Tela = (TipoTela)54, + Versao = LoginViewModel.VersaoAtual, + NomeMaquina = Environment.MachineName, + UsuarioMaquina = Environment.UserName, + Ip = hostEntry.AddressList.FirstOrDefault((IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork)?.ToString() + }; + SaveLog(keyValues, commited); + } + } + ((GenericUnitOfWork)commited).Commit(); + return vendedor; + } + finally + { + ((IDisposable)commited)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)241, tries, new { vendedor, repasses }); + } + } + return vendedorOriginal; + }); + } + + public async Task<Repasse> Save(Repasse repasse) + { + int tries = 3; + base.Sucesso = true; + DateTime now = Funcoes.GetNetworkTime(); + Repasse repasseSave = repasse; + return await Task.Run((Func<Repasse>)delegate + { + //IL_002e: Unknown result type (might be due to invalid IL or missing references) + //IL_0033: Unknown result type (might be due to invalid IL or missing references) + //IL_003a: Unknown result type (might be due to invalid IL or missing references) + //IL_0045: Unknown result type (might be due to invalid IL or missing references) + //IL_0051: Unknown result type (might be due to invalid IL or missing references) + //IL_0058: Unknown result type (might be due to invalid IL or missing references) + //IL_005d: Unknown result type (might be due to invalid IL or missing references) + //IL_0069: Expected O, but got Unknown + //IL_006e: Unknown result type (might be due to invalid IL or missing references) + //IL_007f: Unknown result type (might be due to invalid IL or missing references) + //IL_0087: Unknown result type (might be due to invalid IL or missing references) + //IL_0092: Unknown result type (might be due to invalid IL or missing references) + //IL_009d: Unknown result type (might be due to invalid IL or missing references) + //IL_00a8: Unknown result type (might be due to invalid IL or missing references) + //IL_00e5: Expected O, but got Unknown + while (tries > 0) + { + try + { + UnitOfWork commited = Instancia.Commited; + try + { + repasseSave = commited.RepasseRepository.Merge(repasseSave); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + RegistroLog keyValues = new RegistroLog + { + Acao = (TipoAcao)1, + Usuario = Recursos.Usuario, + DataHora = now, + Descricao = JsonConvert.SerializeObject((object)repasse, new JsonSerializerSettings + { + ReferenceLoopHandling = (ReferenceLoopHandling)1 + }), + EntidadeId = ((DomainBase)repasse).Id, + Tela = (TipoTela)54, + Versao = LoginViewModel.VersaoAtual, + NomeMaquina = Environment.MachineName, + UsuarioMaquina = Environment.UserName, + Ip = hostEntry.AddressList.FirstOrDefault((IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork)?.ToString() + }; + SaveLog(keyValues, commited); + ((GenericUnitOfWork)commited).Commit(); + return repasseSave; + } + finally + { + ((IDisposable)commited)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)241, tries, new { repasse }); + } + } + return repasse; + }); + } + + public async Task<bool> Delete(Vendedor vendedor) + { + int tries = 3; + DateTime dateHora = Funcoes.GetNetworkTime(); + return await Task.Run(delegate + { + //IL_002d: Unknown result type (might be due to invalid IL or missing references) + //IL_0033: Expected O, but got Unknown + while (tries > 0) + { + try + { + UnitOfWork commited = Instancia.Commited; + try + { + commited.VendedorRepository.Delete(((DomainBase)vendedor).Id); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + RegistroLog val = new RegistroLog(); + val.Acao = (TipoAcao)2; + val.Usuario = Recursos.Usuario; + val.DataHora = dateHora; + val.Descricao = $"O USUĂRIO {Recursos.Usuario.Nome} EXCLUIU, EM {dateHora}, O VENDEDOR DE " + $"ID: '{((DomainBase)vendedor).Id}'" + ", NOME: '" + (string.IsNullOrWhiteSpace(vendedor.Nome) ? "" : (vendedor.Nome ?? "")) + "', DOCUMENTO: '" + (string.IsNullOrWhiteSpace(vendedor.Documento) ? "" : (vendedor.Documento ?? "")) + "', BANCO: '" + ((vendedor.Banco == null) ? "" : (vendedor.Banco.Nome ?? "")) + "', CONTA: '" + (string.IsNullOrWhiteSpace(vendedor.Conta) ? "" : (vendedor.Conta ?? "")) + "'."; + val.EntidadeId = ((DomainBase)vendedor).Id; + val.Tela = (TipoTela)15; + val.Versao = LoginViewModel.VersaoAtual; + val.NomeMaquina = Environment.MachineName; + val.UsuarioMaquina = Environment.UserName; + val.Ip = hostEntry.AddressList.FirstOrDefault((IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork)?.ToString(); + RegistroLog val2 = val; + if (vendedor.Telefones != null && vendedor.Telefones.Count != 0) + { + foreach (VendedorTelefone telefone in vendedor.Telefones) + { + val2.Descricao += string.Format(", TELEFONE {0}: {1} ({2}) {3}", vendedor.Telefones.IndexOf(telefone), (!((TelefoneBase)telefone).Tipo.HasValue) ? "-" : ValidationHelper.GetDescription((Enum)(object)((TelefoneBase)telefone).Tipo), string.IsNullOrWhiteSpace(((TelefoneBase)telefone).Prefixo) ? "" : (((TelefoneBase)telefone).Prefixo ?? ""), string.IsNullOrWhiteSpace(((TelefoneBase)telefone).Numero) ? "" : (((TelefoneBase)telefone).Numero ?? "")); + } + } + val2.Descricao += "."; + SaveLog(val2, commited); + ((GenericUnitOfWork)commited).Commit(); + return true; + } + finally + { + ((IDisposable)commited)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)242, tries, vendedor); + } + } + return false; + }); + } + + public async Task<ObservableCollection<Repasse>> BuscaRepassesPorIdVendedor(long id) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return new ObservableCollection<Repasse>(read.RepasseRepository.FindByIdVendedor(id)); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)143, tries, id); + } + } + return new ObservableCollection<Repasse>(); + }); + } + + public async Task<List<VendedorParcela>> BuscarVendedorParcela(long id) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return read.RepasseRepository.FindByIdRepasse(id); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)143, tries, id); + } + } + return new List<VendedorParcela>(); + }); + } + + public async Task<Vendedor> BuscarCorretora() + { + return await Task.Run((Func<Vendedor>)delegate + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return read.VendedorRepository.FindCorretora(); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception) + { + return (Vendedor)null; + } + }); + } + + public async Task<List<Vendedor>> BuscarVinculosCliente(long idCliente) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + if (Recursos.Usuario.IdEmpresa != 1) + { + _ = Recursos.Usuario.IdEmpresa; + } + return read.VendedorParcelaRepository.FindVinculoByIdCliente(idCliente); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)143, tries); + } + } + return (List<Vendedor>)null; + }); + } +} |