From 1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1 Mon Sep 17 00:00:00 2001 From: Lucas Faria Mendes Date: Mon, 30 Mar 2026 10:38:18 -0300 Subject: chore: location --- .../Gestor.Infrastructure.Mappers/CustomMap.cs | 1185 ++++++++++++++++++++ 1 file changed, 1185 insertions(+) create mode 100644 Codemerx/Gestor.Infrastructure/Gestor.Infrastructure.Mappers/CustomMap.cs (limited to 'Codemerx/Gestor.Infrastructure/Gestor.Infrastructure.Mappers/CustomMap.cs') diff --git a/Codemerx/Gestor.Infrastructure/Gestor.Infrastructure.Mappers/CustomMap.cs b/Codemerx/Gestor.Infrastructure/Gestor.Infrastructure.Mappers/CustomMap.cs new file mode 100644 index 0000000..7f7574b --- /dev/null +++ b/Codemerx/Gestor.Infrastructure/Gestor.Infrastructure.Mappers/CustomMap.cs @@ -0,0 +1,1185 @@ +using Gestor.Common.Validation; +using Gestor.Infrastructure.Helpers; +using Gestor.Model.API; +using Gestor.Model.Common; +using Gestor.Model.Domain.Aggilizador; +using Gestor.Model.Domain.Common; +using Gestor.Model.Domain.Ferramentas; +using Gestor.Model.Domain.Financeiro; +using Gestor.Model.Domain.Generic; +using Gestor.Model.Domain.Relatorios; +using Gestor.Model.Domain.Seguros; +using System; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Runtime.CompilerServices; + +namespace Gestor.Infrastructure.Mappers +{ + public static class CustomMap + { + public static Usuario FromUserSso(this Usuario usuario, UserSso userSso) + { + usuario.SsoId = userSso.Id; + usuario.Nome = userSso.Name; + usuario.Login = userSso.Username; + usuario.Excluido = userSso.IsDeleted; + if (userSso.Password.IsNotNullOrEmpty()) + { + usuario.Senha = userSso.Password; + } + return usuario; + } + + public static List MapAdiantamento(this DataTable data) + { + if (data == null) + { + return null; + } + return data.AsEnumerable().Select((DataRow x) => new Adiantamento() + { + Id = x.Field("idadiantamento"), + Vendedor = Auxiliar.Vendedores.Find((Vendedor v) => v.Id == x.Field("idvendedor")), + TipoPagamento = (x.Field("idtipopagto") != null ? new TipoPagamento?((TipoPagamento)int.Parse(x.Field("idtipopagto").ToString())) : null), + Historico = x.Field("historico"), + Data = x.Field("data"), + Valor = x.Field("valor").GetValueOrDefault(), + Pago = (x.Field("pago") == null ? false : x.Field("pago").ToString() == "1"), + Pagamento = x.Field("Pagamento") + }).ToList(); + } + + public static List MapArquivoVinculo(DataTable data) + { + return data.AsEnumerable().Select((DataRow x) => new ArquivoVinculo() + { + Id = x.Field("Id"), + Arquivo = x.Field("Arquivo"), + IdVinculo = x.Field("IdVinculo"), + Chave = x.Field("Chave"), + Ano = x.Field("Ano"), + Storage = x.Field("Storage") + }).ToList(); + } + + internal static List MapCamposRelatorio(this DataTable data) + { + return ( + from x in data.AsEnumerable().ToList() + select new ParametrosRelatorio() + { + Id = x.Field("Id"), + IdUsuario = x.Field("IdUsuario"), + Relatorio = (Relatorio)x.Field("Relatorio"), + Campo = x.Field("Campo"), + Header = x.Field("Header"), + Width = x.Field("Width").GetValueOrDefault(), + Tipo = x.Field("Tipo"), + Ordem = x.Field("Ordem") + }).ToList(); + } + + internal static List MapCliente(this DataTable data) + { + return ( + from x in data.AsEnumerable().ToList() + select new Cliente() + { + Id = x.Field("id"), + IdEmpresa = x.Field("idempresa"), + Nome = x.Field("nome"), + Documento = x.Field("documento"), + Cei = x.Field("cei"), + Rne = x.Field("rne"), + DocumentoPrincipal = new TipoDocumento?((x.Field("documentoprincipal") == null ? TipoDocumento.Cpf : (TipoDocumento)Enum.Parse(typeof(TipoDocumento), x.Field("documentoprincipal").ToString()))), + Observacao = x.Field("anotacoes"), + Nascimento = x.Field("nascimento"), + Profissao = (x.Field("idprofissao") == null ? null : Auxiliar.Profissoes.Find((Profissao p) => p.Id == x.Field("idprofissao"))), + VencimentoHabilitacao = x.Field("vencimento"), + RendaMensal = x.Field("RendaMensal").GetValueOrDefault(), + Pasta = x.Field("pasta"), + MalaDireta = new bool?(x.Field("MalaDireta").GetValueOrDefault(true)) + }).ToList(); + } + + internal static List MapConta(DataTable data) + { + return data.AsEnumerable().Select((DataRow x) => new BancosContas() + { + Id = x.Field("idconta"), + IdEmpresa = x.Field("idempresa"), + Banco = Auxiliar.Banco.Find((Banco u) => u.Id == x.Field("idcodigobanco")), + Descricao = x.Field("descricao"), + Agencia = x.Field("agencia"), + Conta = x.Field("conta"), + Observacao = x.Field("obs"), + Ativo = (x.Field("ativo") == null ? true : x.Field("ativo").ToString() == "1") + }).ToList(); + } + + internal static List MapDocumento(this DataTable data, List sinistros) + { + return data.AsEnumerable().Select((DataRow x) => { + Documento documento = new Documento() + { + Id = x.Field("iddocumento"), + Controle = new Controle() + { + Id = x.Field("idcontrole"), + IdEmpresa = (x.Field("idempresa") != null ? x.Field("idempresa") : (long)1), + Cliente = new Cliente() + { + Id = x.Field("idcliente") + }, + Seguradora = (x.Field("idciaseg") != null ? Auxiliar.Seguradoras.Find((Seguradora p) => p.Id == x.Field("idciaseg")) : null), + Ramo = (x.Field("idramo") != null ? Auxiliar.Ramos.Find((Ramo p) => p.Id == x.Field("idramo")) : null), + Produto = (x.Field("idproduto") != null ? Auxiliar.Produtos.Find((Produto p) => p.Id == x.Field("idproduto")) : null) + }, + Ordem = x.Field("ordem"), + TipoRecebimento = new TipoRecebimento?((TipoRecebimento)Enum.Parse(typeof(TipoRecebimento), x.Field("tiporecebimento").ToString())), + AdicionalComiss = x.Field("adinacomis") == "1", + PremioAdicional = x.Field("pr_adic"), + Proposta = x.Field("proposta"), + Apolice = x.Field("contrato"), + PropostaEndosso = x.Field("pedadit"), + Endosso = x.Field("aditamento"), + Comissao = x.Field("com01"), + Negocio = new Negocio?((x.Field("idnegocio") == null ? Negocio.Proprio : (Negocio)Enum.Parse(typeof(Negocio), x.Field("idnegocio").ToString()))), + PremioLiquido = x.Field("pr_liq"), + PremioTotal = x.Field("pr_total"), + Vigencia2 = x.Field("vigencia2") + }; + DateTime? nullable = x.Field("vigencia1"); + documento.Vigencia1 = (nullable.HasValue ? nullable.GetValueOrDefault() : DateTime.MinValue); + documento.Emissao = x.Field("emissao"); + documento.Remessa = x.Field("remessa"); + documento.Estipulante1 = (x.Field("idestipulante") != null ? Auxiliar.Estipulantes.Find((Estipulante p) => p.Id == x.Field("idestipulante")) : null); + documento.NegocioCorretora = new NegocioCorretora?((x.Field("negociocorretora") == null ? NegocioCorretora.Proprio : (NegocioCorretora)Enum.Parse(typeof(NegocioCorretora), x.Field("negociocorretora").ToString()))); + documento.Situacao = (TipoSeguro)Enum.Parse(typeof(TipoSeguro), x.Field("situacao").ToString()); + documento.Tipo = x.Field("tipo"); + documento.Sinistro = (sinistros == null ? false : sinistros.Any((long s) => s == x.Field("idcontrole"))); + documento.NumeroParcelas = x.Field("numeroParcelas"); + documento.Pasta = x.Field("Pasta"); + documento.Agencia = x.Field("agencia"); + documento.Conta = x.Field("conta"); + documento.Excluido = (x.Field("excluido") == null ? false : x.Field("excluido").ToString() == "1"); + return documento; + }).ToList(); + } + + public static List MapEmail(DataTable data) + { + return data.AsEnumerable().Select((DataRow x) => { + string str; + string str1; + ClienteEmail clienteEmail = new ClienteEmail() + { + Id = x.Field("Id"), + Cliente = new Cliente() + { + Id = x.Field("IdCliente"), + Nome = x.Field("NomeCliente") + } + }; + string str2 = x.Field("Email"); + if (str2 != null) + { + str = str2.Trim(); + } + else + { + str = null; + } + clienteEmail.Email = str; + string str3 = x.Field("Observacao"); + if (str3 != null) + { + str1 = str3.Trim(); + } + else + { + str1 = null; + } + clienteEmail.Observacao = str1; + clienteEmail.Ordem = x.Field("Ordem"); + return clienteEmail; + }).ToList(); + } + + public static List MapEndereco(this DataTable data) + { + return data.AsEnumerable().Select((DataRow x) => new ClienteEndereco() + { + Id = x.Field("idcliend"), + Endereco = x.Field("endereco"), + Bairro = x.Field("bairro"), + Estado = x.Field("uf"), + Cep = x.Field("cep"), + Numero = x.Field("numero"), + Cidade = x.Field("cidade"), + Complemento = x.Field("comp_end"), + Cliente = new Cliente() + { + Id = x.Field("idcliente"), + Nome = x.Field("nomecliente") + }, + Ordem = x.Field("Ordem"), + Observacao = x.Field("obs") + }).ToList(); + } + + internal static List MapEstipulante(this DataTable data) + { + return data.AsEnumerable().Select((DataRow x) => { + string str; + string str1; + string str2; + string str3; + string str4; + Estipulante estipulante = new Estipulante() + { + IdEmpresa = x.Field("idempresa").GetValueOrDefault((long)1), + Id = x.Field("idestipulante"), + Nome = x.Field("nome"), + Documento = x.Field("cpfcnpj"), + Ativo = (x.Field("ativo") == null ? true : x.Field("ativo").ToString() == "1"), + Cep = x.Field("cep"), + Cidade = x.Field("cidade"), + Estado = x.Field("uf"), + Bairro = x.Field("bairro"), + Endereco = x.Field("endereco"), + Numero = x.Field("numero"), + Complemento = x.Field("complemento"), + PrimeiroTipo = new TipoTelefone?((x.Field("idfonetipo1") == null ? TipoTelefone.Outros : int.Parse(x.Field("idfonetipo1").ToString()))) + }; + string str5 = x.Field("ddd1"); + if (str5 != null) + { + str = str5.Trim(); + } + else + { + str = null; + } + estipulante.PrimeiroPrefixo = str; + string str6 = x.Field("fone1"); + if (str6 != null) + { + str1 = str6.Trim(); + } + else + { + str1 = null; + } + estipulante.PrimeiroTelefone = str1; + estipulante.SegundoTipo = new TipoTelefone?((x.Field("idfonetipo2") == null ? TipoTelefone.Outros : int.Parse(x.Field("idfonetipo2").ToString()))); + string str7 = x.Field("ddd2"); + if (str7 != null) + { + str2 = str7.Trim(); + } + else + { + str2 = null; + } + estipulante.SegundoPrefixo = str2; + string str8 = x.Field("fone2"); + if (str8 != null) + { + str3 = str8.Trim(); + } + else + { + str3 = null; + } + estipulante.SegundoTelefone = str3; + string str9 = x.Field("email"); + if (str9 != null) + { + str4 = str9.Trim(); + } + else + { + str4 = null; + } + estipulante.Email = str4; + estipulante.Observacao = (x.Field("obs") != null ? x.Field("obs").ToString() : null); + return estipulante; + }).ToList(); + } + + public static List MapExtrato(DataTable data, DataTable parcelas = null) + { + return data.AsEnumerable().ToList().Select((DataRow x) => { + Extrato extrato = new Extrato() + { + Id = x.Field("idextrato") + }; + decimal? nullable = x.Field("bruto"); + extrato.Bruto = new decimal?(nullable.GetValueOrDefault()); + extrato.Data = x.Field("data"); + DateTime? nullable1 = x.Field("DataCredito"); + extrato.DataCredito = (nullable1.HasValue ? nullable1 : x.Field("data")); + extrato.Historico = x.Field("historico"); + nullable = x.Field("ir"); + extrato.Ir = new decimal?(nullable.GetValueOrDefault()); + nullable = x.Field("iss"); + extrato.Iss = new decimal?(nullable.GetValueOrDefault()); + nullable = x.Field("liquido"); + extrato.Liquido = new decimal?(nullable.GetValueOrDefault()); + extrato.Numero = x.Field("extrato"); + extrato.Observacao = (x.Field("obsextrato") == null ? "" : x.Field("obsextrato").ToString()); + extrato.Seguradora = (x.Field("idciaseg") != null ? Auxiliar.Seguradoras.FirstOrDefault((Seguradora p) => p.Id == x.Field("idciaseg")) : null); + nullable = x.Field("outro"); + extrato.Outro = new decimal?(nullable.GetValueOrDefault()); + extrato.Status = (x.Field("idstatusextrato") == null ? StatusExtrato.Pendente : (x.Field("idstatusextrato").ToString() == "2" ? StatusExtrato.Baixado : (StatusExtrato)Enum.Parse(typeof(StatusExtrato), x.Field("idstatusextrato").ToString()))); + extrato.IdEmpresa = x.Field("idempresa"); + extrato.Completo = (parcelas == null ? false : parcelas.AsEnumerable().All((DataRow p) => p.Field("idextrato") != x.Field("idextrato"))); + extrato.IdUsuario = x.Field("usuariocriacao"); + return extrato; + }).ToList(); + } + + internal static List MapFornecedor(DataTable data) + { + return data.AsEnumerable().Select((DataRow x) => { + TipoTelefone? nullable; + TipoTelefone? nullable1; + TipoTelefone? nullable2; + Fornecedor fornecedor = new Fornecedor() + { + Id = x.Field("idfornecedor"), + Nome = x.Field("nome"), + Documento = x.Field("cpfcnpj") + }; + if (x.Field("idfonetipo1") != null) + { + nullable1 = new TipoTelefone?((TipoTelefone)int.Parse(x.Field("idfonetipo1").ToString())); + } + else + { + nullable = null; + nullable1 = nullable; + } + fornecedor.TipoTelefone1 = nullable1; + fornecedor.Prefixo1 = x.Field("ddd1"); + fornecedor.Telefone1 = x.Field("fone1"); + if (x.Field("idfonetipo2") != null) + { + nullable2 = new TipoTelefone?((TipoTelefone)int.Parse(x.Field("idfonetipo2").ToString())); + } + else + { + nullable = null; + nullable2 = nullable; + } + fornecedor.TipoTelefone2 = nullable2; + fornecedor.Prefixo2 = x.Field("ddd2"); + fornecedor.Telefone2 = x.Field("fone2"); + fornecedor.Email = x.Field("email"); + fornecedor.Complemento = x.Field("complemento"); + fornecedor.Cidade = x.Field("cidade"); + fornecedor.Bairro = x.Field("bairro"); + fornecedor.Numero = x.Field("numero"); + fornecedor.Cep = x.Field("cep"); + fornecedor.Estado = x.Field("uf"); + fornecedor.Endereco = x.Field("endereco"); + fornecedor.IdCentro = x.Field("idcentro"); + fornecedor.IdConta = x.Field("idconta"); + fornecedor.IdPlano = x.Field("idcplanos"); + fornecedor.IdEmpresa = x.Field("idempresa"); + fornecedor.Observacao = x.Field("observacao"); + fornecedor.TipoPagamento = (x.Field("idtipopagto") != null ? new TipoPagamento?((TipoPagamento)int.Parse(x.Field("idtipopagto").ToString())) : null); + fornecedor.Ativo = x.Field("Ativo"); + return fornecedor; + }).ToList(); + } + + internal static List MapImportacao(this DataTable data) + { + return data.AsEnumerable().ToList().Select((DataRow x) => { + CriticaApolice criticaApolouse = new CriticaApolice() + { + Id = x.Field("id"), + UsuarioImportacao = (x.Field("idusuario") != null ? Auxiliar.Usuarios.Find((Usuario p) => p.Id == x.Field("idusuario")) : null), + Critica = new bool?((x.Field("critica") == null ? false : x.Field("critica").ToString() == "1")) + }; + DateTime? nullable = x.Field("dataimportacao"); + criticaApolouse.DataImportacao = new DateTime?((nullable.HasValue ? nullable.GetValueOrDefault() : DateTime.MinValue)); + criticaApolouse.Tipo = x.Field("tipo"); + criticaApolouse.Documento = new Documento() + { + Id = x.Field("iddocumento"), + Controle = new Controle() + { + Id = x.Field("idcontrole"), + Seguradora = Auxiliar.Seguradoras.Find((Seguradora s) => s.Id == x.Field("idciaseg")), + Ramo = Auxiliar.Ramos.Find((Ramo s) => s.Id == x.Field("idramo")), + Cliente = new Cliente() + { + Id = x.Field("idcliente"), + Nome = x.Field("cliente"), + Documento = x.Field("documento"), + Cei = x.Field("cei"), + Rne = x.Field("rne"), + DocumentoPrincipal = new TipoDocumento?((x.Field("documentoprincipal") == null ? TipoDocumento.Cpf : (TipoDocumento)Enum.Parse(typeof(TipoDocumento), x.Field("documentoprincipal").ToString()))) + } + }, + Apolice = x.Field("apolice"), + Proposta = x.Field("proposta"), + Vigencia1 = x.Field("vigencia1"), + Vigencia2 = x.Field("vigencia2") + }; + criticaApolouse.UsuarioCritica = x.Field("idusuariocritica"); + criticaApolouse.DataCritica = x.Field("datacritica"); + return criticaApolouse; + }).ToList(); + } + + public static List MapImposto(DataTable data) + { + return data.AsEnumerable().Select((DataRow x) => new Imposto() + { + Id = x.Field("Id"), + Seguradora = (x.Field("idciaseg") != null ? Auxiliar.Seguradoras.Find((Seguradora s) => s.Id == x.Field("idciaseg")) : null), + Ramo = (x.Field("idramo") != null ? Auxiliar.Ramos.Find((Ramo s) => s.Id == x.Field("idramo")) : null), + Ir = x.Field("Ir"), + Iss = x.Field("Iss"), + Outros = x.Field("Outros"), + Desconto = x.Field("Desconto"), + Ativo = x.Field("Ativo") + }).ToList(); + } + + public static List MapLancamento(DataTable data) + { + return data.AsEnumerable().Select((DataRow x) => { + object fornecedor; + Lancamento lancamento = new Lancamento() + { + Id = x.Field("idlancamen") + }; + ControleFinanceiro controleFinanceiro = new ControleFinanceiro() + { + Id = x.Field("idcfinan") + }; + if (x.Field("idfornecedor") != null) + { + fornecedor = new Fornecedor(); + ((Fornecedor)fornecedor).Id = x.Field("idfornecedor"); + ((Fornecedor)fornecedor).Nome = x.Field("nome"); + bool? nullable = x.Field("Ativo"); + ((Fornecedor)fornecedor).Ativo = nullable.GetValueOrDefault(); + } + else + { + fornecedor = null; + } + controleFinanceiro.Fornecedor = (Fornecedor)fornecedor; + controleFinanceiro.Plano = (x.Field("idcplanos") != null ? AuxiliarFinanceiro.Planos.Find((Planos p) => p.Id == x.Field("idcplanos")) : null); + controleFinanceiro.Centro = (x.Field("idcentro") != null ? AuxiliarFinanceiro.Centros.Find((Centro p) => p.Id == x.Field("idcentro")) : null); + controleFinanceiro.Historico = x.Field("historicocfinan"); + controleFinanceiro.Parcelas = x.Field("parcelas"); + lancamento.Controle = controleFinanceiro; + lancamento.Historico = x.Field("historico"); + lancamento.Documento = x.Field("documento"); + lancamento.Complemento = x.Field("complemento"); + lancamento.Competencia = x.Field("competencia"); + lancamento.Parcela = x.Field("parcela"); + decimal? nullable1 = x.Field("vlrpre"); + lancamento.Valor = nullable1.GetValueOrDefault(); + lancamento.Vencimento = x.Field("dtpre"); + nullable1 = x.Field("vlrbaixa"); + lancamento.ValorPago = new decimal?(nullable1.GetValueOrDefault()); + lancamento.Baixa = x.Field("dtbaixa"); + lancamento.Pagamento = x.Field("dtpagto"); + lancamento.Conta = AuxiliarFinanceiro.Contas.Find((BancosContas p) => p.Id == x.Field("idconta")); + lancamento.Sinal = (Sinal)Enum.Parse(typeof(Sinal), x.Field("sinal").ToString()); + lancamento.TipoPagamento = (x.Field("idtipopagto") != null ? (TipoPagamento)Enum.Parse(typeof(TipoPagamento), x.Field("idtipopagto").ToString()) : TipoPagamento.Nenhum); + lancamento.Observacao = x.Field("obs"); + lancamento.Baixado = x.Field("dtbaixa").HasValue; + lancamento.CodigoBanco = x.Field("CodigoBanco"); + lancamento.DataLancamento = x.Field("datacriacao"); + return lancamento; + }).ToList(); + } + + internal static List MapLogAcao(DataTable data) + { + return data.AsEnumerable().Select((DataRow x) => new RegistroAcao() + { + Id = x.Field("Id"), + EntidadeId = x.Field("EntidadeId"), + Tela = (x.Field("Tela") != null ? new TipoTela?((TipoTela)x.Field("Tela")) : null), + Relatorio = (x.Field("Relatorio") != null ? new Relatorio?((Relatorio)x.Field("Relatorio")) : null), + Usuario = Auxiliar.Usuarios.Find((Usuario u) => u.Id == x.Field("IdUsuario")), + DataHora = x.Field("DataHora"), + Descricao = x.Field("Descricao"), + Observacao = x.Field("Observacao"), + Ip = x.Field("Ip"), + NomeMaquina = x.Field("NomeMaquina"), + UsuarioMaquina = x.Field("UsuarioMaquina"), + Versao = x.Field("Versao") + }).ToList(); + } + + internal static List MapMaisContatos(this DataTable data, Cliente cliente) + { + return ( + from x in data.AsEnumerable().ToList() + select new MaisContato() + { + Id = x.Field("idclicontato"), + Cliente = cliente, + Profissao = (x.Field("idprofissao") != null ? Auxiliar.Profissoes.Find((Profissao p) => p.Id == x.Field("idprofissao")) : null), + Nome = x.Field("contato"), + Tipo = (x.Field("tipo") != null ? new TipoTelefone?((TipoTelefone)int.Parse(x.Field("tipo").ToString())) : null), + Nascimento = x.Field("dtnasc"), + Documento = x.Field("cgccpf"), + Identidade = x.Field("rg"), + Expedicao = x.Field("rgexpedicao"), + Parentesco = (x.Field("idparentesco") != null ? new Parentesco?((Parentesco)((int)long.Parse(x.Field("idparentesco").ToString()))) : null), + Prefixo = x.Field("ddd"), + Telefone = x.Field("fone"), + Email = x.Field("email"), + Habilitacao = x.Field("cnh"), + PrimeiraHabilitacao = x.Field("prihabilitacao"), + Banco = x.Field("banco"), + Agencia = x.Field("agencia"), + Conta = x.Field("conta"), + Excluido = (x.Field("excluido") == null ? false : x.Field("excluido") == "1") + }).ToList(); + } + + internal static List MapManutencao(this DataTable data) + { + return data.AsEnumerable().ToList().Select((DataRow x) => { + string str; + string nome; + string nomeSocial; + string nome1; + string str1; + ManutencaoPagamentos manutencaoPagamento = new ManutencaoPagamentos() + { + Id = x.Field("idvendedorparcela"), + IdParcela = x.Field("idparcela"), + IdDocumento = x.Field("iddocumento") + }; + string str2 = x.Field("nomecliente"); + if (str2 != null) + { + str = str2.Trim(); + } + else + { + str = null; + } + manutencaoPagamento.Nome = str; + Empresa empresa = Auxiliar.Empresas.Find((Empresa e) => e.Id == x.Field("idempresa")); + if (empresa != null) + { + nome = empresa.Nome; + } + else + { + nome = null; + } + manutencaoPagamento.Empresa = nome; + manutencaoPagamento.Apolice = x.Field("apolice"); + manutencaoPagamento.Endosso = x.Field("endosso"); + Seguradora seguradora = Auxiliar.Seguradoras.Find((Seguradora s) => s.Id == x.Field("idseguradora")); + if (seguradora != null) + { + nomeSocial = seguradora.NomeSocial; + } + else + { + nomeSocial = null; + } + manutencaoPagamento.Seguradora = nomeSocial; + Ramo ramo = Auxiliar.Ramos.Find((Ramo s) => s.Id == x.Field("idramo")); + if (ramo != null) + { + nome1 = ramo.Nome; + } + else + { + nome1 = null; + } + manutencaoPagamento.Ramo = nome1; + if (x.Field("idproduto") == null) + { + str1 = ""; + } + else + { + Produto produto = Auxiliar.Produtos.Find((Produto s) => s.Id == x.Field("idproduto")); + if (produto != null) + { + str1 = produto.Nome; + } + else + { + str1 = null; + } + } + manutencaoPagamento.Produto = str1; + manutencaoPagamento.Parcela = int.Parse(x.Field("numeroparcela").ToString()); + manutencaoPagamento.Tipo = (x.Field("idsubtipo") == null ? SubTipo.ParcelaNormal : int.Parse(x.Field("idsubtipo").ToString())); + decimal? nullable = x.Field("valor"); + manutencaoPagamento.Valor = nullable.GetValueOrDefault(); + manutencaoPagamento.Recebimento = x.Field("datarecebimento"); + manutencaoPagamento.Vendedor = x.Field("nomevendedor"); + DateTime? nullable1 = x.Field("dataprepagamento"); + manutencaoPagamento.PrevisaoPagamento = (nullable1.HasValue ? nullable1.GetValueOrDefault() : x.Field("datapagamento")); + manutencaoPagamento.Pagamento = x.Field("datapagamento"); + nullable = x.Field("vlrrep"); + manutencaoPagamento.ValorRepasse = nullable.GetValueOrDefault(); + return manutencaoPagamento; + }).ToList(); + } + + internal static List MapOldLogAcao(DataTable data) + { + List registroAcaos = new List(); + data.AsEnumerable().ToList().ForEach((DataRow x) => { + TipoTela? nullable = x.Field("FORM").Convert(); + Relatorio? nullable1 = x.Field("FORM").ConvertRelatorio(); + if (!nullable.HasValue && !nullable1.HasValue) + { + nullable = new TipoTela?(TipoTela.Todas); + } + RegistroAcao registroAcao = new RegistroAcao() + { + Id = x.Field("IDACTION"), + EntidadeId = x.Field("ID"), + Tela = nullable, + Relatorio = nullable1, + Usuario = Auxiliar.Usuarios.Find((Usuario u) => u.Id == x.Field("IDUSUARIO")), + DataHora = x.Field("DATA"), + Descricao = x.Field("ACAO"), + Observacao = x.Field("historico"), + NomeMaquina = x.Field("maquina") + }; + registroAcaos.Add(registroAcao); + }); + return registroAcaos; + } + + internal static List MapParcela(this DataTable data, Documento documento) + { + return data.AsEnumerable().Select((DataRow x) => { + Parcela parcela = new Parcela() + { + Id = x.Field("idparcela"), + IdEmpresa = x.Field("idempresa"), + Documento = documento, + NumeroParcela = (x.Field("parcela") != null ? int.Parse(x.Field("parcela").ToString()) : 1) + }; + DateTime? nullable = x.Field("vencto"); + parcela.Vencimento = (nullable.HasValue ? nullable.GetValueOrDefault() : documento.Vigencia1); + parcela.DataRecebimento = x.Field("datarec"); + parcela.DataQuitacao = x.Field("dataquit"); + parcela.DataCredito = x.Field("datacred"); + decimal? nullable1 = x.Field("valor"); + parcela.Valor = nullable1.GetValueOrDefault(); + nullable1 = x.Field("valorp"); + parcela.ValorPago = nullable1.GetValueOrDefault(); + nullable1 = x.Field("valorr"); + parcela.ValorRealizado = nullable1.GetValueOrDefault(); + nullable1 = x.Field("comiss"); + parcela.Comissao = nullable1.GetValueOrDefault(); + nullable1 = x.Field("vlrcomiss"); + parcela.ValorComissao = nullable1.GetValueOrDefault(); + parcela.Observacao = (x.Field("obs") != null ? x.Field("obs").ToString() : ""); + parcela.Extrato = x.Field("extrato"); + nullable1 = x.Field("irr"); + parcela.Irr = nullable1.GetValueOrDefault(); + nullable1 = x.Field("iss"); + parcela.Iss = nullable1.GetValueOrDefault(); + nullable1 = x.Field("outros"); + parcela.Outros = nullable1.GetValueOrDefault(); + nullable1 = x.Field("desconto"); + parcela.Desconto = nullable1.GetValueOrDefault(); + nullable1 = x.Field("vlrextrato"); + parcela.ValorExtrato = nullable1.GetValueOrDefault(); + nullable1 = x.Field("vlrcomdesc"); + parcela.ValorComDesconto = nullable1.GetValueOrDefault(); + parcela.SubTipo = (x.Field("idsubtipo") == null ? SubTipo.ParcelaNormal : int.Parse(x.Field("idsubtipo").ToString())); + parcela.TipoPagamento = (x.Field("idtipopagto") == null ? TipoPagamento.Nenhum : int.Parse(x.Field("idtipopagto").ToString())); + nullable1 = x.Field("valorlf"); + parcela.ValorLiquidoFatura = nullable1.GetValueOrDefault(); + parcela.DataCriacao = x.Field("cri_data"); + long? nullable2 = x.Field("usuariocriacao"); + parcela.UsuarioCriacao = nullable2.GetValueOrDefault(); + parcela.DataControle = x.Field("datacontrole"); + parcela.Fatura = x.Field("fatura"); + parcela.VigenciaIncial = x.Field("vigenciainicial"); + parcela.VigenciaFinal = x.Field("vigenciafinal"); + parcela.Emissao = x.Field("emissao"); + parcela.StatusPagamento = new StatusPagamento?((x.Field("StatusPagamento") == null ? StatusPagamento.All : (StatusPagamento)Enum.Parse(typeof(StatusPagamento), x.Field("StatusPagamento").ToString()))); + nullable2 = x.Field("IdParcelaPendente"); + parcela.IdParcelaPendente = nullable2.GetValueOrDefault(); + return parcela; + }).ToList(); + } + + internal static Parcela MapParcela(this DataRow data) + { + SubTipo subTipo; + TipoPagamento tipoPagamento; + if (data == null) + { + return null; + } + Parcela parcela = new Parcela() + { + Id = data.Field("idparcela"), + IdEmpresa = data.Field("idempresa"), + Documento = new Documento() + { + Id = data.Field("iddocumento") + }, + NumeroParcela = (data.Field("parcela") != null ? int.Parse(data.Field("parcela").ToString()) : 1) + }; + DateTime? nullable = data.Field("vencto"); + parcela.Vencimento = (nullable.HasValue ? nullable.GetValueOrDefault() : DateTime.Now); + parcela.DataRecebimento = data.Field("datarec"); + parcela.DataQuitacao = data.Field("dataquit"); + parcela.DataCredito = data.Field("datacred"); + decimal? nullable1 = data.Field("valor"); + parcela.Valor = nullable1.GetValueOrDefault(); + nullable1 = data.Field("valorp"); + parcela.ValorPago = nullable1.GetValueOrDefault(); + nullable1 = data.Field("valorr"); + parcela.ValorRealizado = nullable1.GetValueOrDefault(); + nullable1 = data.Field("comiss"); + parcela.Comissao = nullable1.GetValueOrDefault(); + nullable1 = data.Field("vlrcomiss"); + parcela.ValorComissao = nullable1.GetValueOrDefault(); + parcela.Observacao = (data.Field("obs") != null ? data.Field("obs").ToString() : ""); + parcela.Extrato = data.Field("extrato"); + nullable1 = data.Field("irr"); + parcela.Irr = nullable1.GetValueOrDefault(); + nullable1 = data.Field("iss"); + parcela.Iss = nullable1.GetValueOrDefault(); + nullable1 = data.Field("outros"); + parcela.Outros = nullable1.GetValueOrDefault(); + nullable1 = data.Field("desconto"); + parcela.Desconto = nullable1.GetValueOrDefault(); + nullable1 = data.Field("vlrextrato"); + parcela.ValorExtrato = nullable1.GetValueOrDefault(); + nullable1 = data.Field("vlrcomdesc"); + parcela.ValorComDesconto = nullable1.GetValueOrDefault(); + if (data.Field("idsubtipo") == null) + { + subTipo = SubTipo.ParcelaNormal; + } + else + { + subTipo = (SubTipo)int.Parse(data.Field("idsubtipo").ToString()); + } + parcela.SubTipo = subTipo; + if (data.Field("idtipopagto") == null) + { + tipoPagamento = TipoPagamento.Nenhum; + } + else + { + tipoPagamento = (TipoPagamento)int.Parse(data.Field("idtipopagto").ToString()); + } + parcela.TipoPagamento = tipoPagamento; + nullable1 = data.Field("valorlf"); + parcela.ValorLiquidoFatura = nullable1.GetValueOrDefault(); + parcela.DataCriacao = data.Field("cri_data"); + long? nullable2 = data.Field("usuariocriacao"); + parcela.UsuarioCriacao = nullable2.GetValueOrDefault(); + parcela.DataControle = data.Field("datacontrole"); + parcela.Fatura = data.Field("fatura"); + parcela.VigenciaIncial = data.Field("vigenciainicial"); + parcela.VigenciaFinal = data.Field("vigenciafinal"); + parcela.Emissao = data.Field("emissao"); + parcela.StatusPagamento = new StatusPagamento?((data.Field("StatusPagamento") == null ? StatusPagamento.All : (StatusPagamento)Enum.Parse(typeof(StatusPagamento), data.Field("StatusPagamento").ToString()))); + nullable2 = data.Field("IdParcelaPendente"); + parcela.IdParcelaPendente = nullable2.GetValueOrDefault(); + return parcela; + } + + internal static List MapPermissao(this DataTable data) + { + return data.AsEnumerable().Select((DataRow x) => new PermissaoUsuario() + { + Id = x.Field("Id"), + Usuario = Auxiliar.Usuarios.Find((Usuario u) => u.Id == x.Field("IdUsuario")), + Tela = (TipoTela)x.Field("Tela"), + Consultar = x.Field("Consultar"), + Incluir = x.Field("Incluir"), + Alterar = x.Field("Alterar"), + Excluir = x.Field("Excluir") + }).ToList(); + } + + internal static List MapPlanos(DataTable data) + { + return data.AsEnumerable().Select((DataRow x) => new Planos() + { + Id = x.Field("id"), + Descricao = x.Field("nome"), + Nome = x.Field("descricao"), + Ativo = (x.Field("ativo") == null ? true : x.Field("ativo").ToString() == "1"), + Plano = AuxiliarFinanceiro.Plano.Find((Plano p) => p.Id == x.Field("idcplano")), + TipoConta = (x.Field("idtipoconta").HasValue ? AuxiliarFinanceiro.TiposConta.Find((Gestor.Model.Domain.Financeiro.TipoConta p) => p.Id == x.Field("idtipoconta")) : null), + Sinal = (x.Field("ctipo") == null ? Sinal.Credito : (Sinal)Enum.Parse(typeof(Sinal), x.Field("ctipo").ToString())) + }).ToList(); + } + + internal static List MapRegistroLog(this DataTable data) + { + return ( + from x in data.AsEnumerable().ToList() + select new RegistroLog() + { + Id = x.Field("Id"), + Usuario = (x.Field("IdUsuario") != null ? Auxiliar.Usuarios.Find((Usuario u) => u.Id == x.Field("IdUsuario")) : null), + EntidadeId = x.Field("EntidadeId"), + Acao = (TipoAcao)x.Field("Acao"), + Tela = (TipoTela)x.Field("Tela"), + Versao = x.Field("Versao"), + DataHora = x.Field("DataHora"), + Descricao = (x.Field("Descricao") == null ? "" : x.Field("Descricao")), + NomeMaquina = x.Field("NomeMaquina"), + UsuarioMaquina = x.Field("UsuarioMaquina"), + Ip = x.Field("Ip"), + ModeloNovo = x.Field("ModeloNovo").GetValueOrDefault() + }).ToList(); + } + + internal static List MapSaldo(DataTable data) + { + return data.AsEnumerable().Select((DataRow x) => { + Saldo saldo = new Saldo() + { + Id = x.Field("idsaldo"), + Conta = AuxiliarFinanceiro.Contas.Find((BancosContas u) => u.Id == x.Field("idconta")) + }; + decimal? nullable = x.Field("vlrinicio"); + saldo.ValorInicio = nullable.GetValueOrDefault(); + saldo.DataInicio = new DateTime?(x.Field("dtinicio")); + nullable = x.Field("vlrfim"); + saldo.ValorFinal = new decimal?(nullable.GetValueOrDefault()); + saldo.DataFinal = x.Field("dtfim"); + saldo.Extrato = x.Field("extrato"); + return saldo; + }).ToList(); + } + + internal static List MapSeguradoraContato(this DataTable data) + { + return ( + from x in data.AsEnumerable().ToList() + select new SeguradoraContato() + { + Id = x.Field("idciacontato"), + Empresa = Auxiliar.Empresas.Find((Empresa e) => e.Id == x.Field("idempresa")), + Seguradora = Auxiliar.Seguradoras.Find((Seguradora s) => s.Id == x.Field("idciaseg")), + NomeContato = x.Field("nome"), + Tipo = (x.Field("idfonetipo") != null ? new TipoTelefone?((TipoTelefone)int.Parse(x.Field("idfonetipo").ToString())) : null), + Prefixo = x.Field("ddd"), + Numero = x.Field("fone"), + Email = x.Field("email"), + TipoContato = (TipoContatoSeguradora)((x.Field("TipoContato") != null ? int.Parse(x.Field("TipoContato").ToString()) : TipoContatoSeguradora.Contato)) + }).ToList(); + } + + internal static List MapSinistro(this DataTable data, DataTable apolice) + { + List sinistros = new List(); + data.AsEnumerable().ToList().ForEach((DataRow x) => { + DataRow dataRow = apolice.AsEnumerable().FirstOrDefault((DataRow d) => d.Field("iditem") == x.Field("iditem")); + if (dataRow == null) + { + return; + } + Sinistro sinistro = new Sinistro() + { + ControleSinistro = new ControleSinistro() + { + Id = x.Field("idcontrolesinistro"), + Item = new Item() + { + Id = dataRow.Field("iditem"), + Documento = new Documento() + { + Id = dataRow.Field("iddocumento"), + Apolice = dataRow.Field("apolice"), + Controle = new Controle() + { + Id = dataRow.Field("idcontrole"), + Cliente = new Cliente() + { + Id = dataRow.Field("idcliente"), + Nome = dataRow.Field("nome") + } + } + } + } + }, + Id = x.Field("idsinistro"), + Numero = x.Field("numsinistro"), + ItemSinistrado = x.Field("itemsinistrado") + }; + sinistros.Add(sinistro); + }); + return sinistros; + } + + public static List MapTarefa(DataTable data, DataTable responsaveis) + { + return data.AsEnumerable().Select((DataRow x) => { + Tarefa tarefa = new Tarefa() + { + Id = x.Field("Id") + }; + long? nullable = x.Field("IdCliente"); + tarefa.IdCliente = nullable.GetValueOrDefault(); + tarefa.Cliente = x.Field("Cliente"); + tarefa.Entidade = (TipoTarefa)x.Field("Entidade"); + nullable = x.Field("IdEntidade"); + tarefa.IdEntidade = nullable.GetValueOrDefault(); + DateTime? nullable1 = x.Field("Agendamento"); + tarefa.Agendamento = (nullable1.HasValue ? nullable1.GetValueOrDefault() : DateTime.Now); + tarefa.Conclusao = x.Field("Conclusao"); + tarefa.Referencia = x.Field("Referencia"); + tarefa.Titulo = x.Field("Titulo"); + tarefa.Descricao = x.Field("Descricao"); + tarefa.DescricaoInterna = x.Field("descricaointerna"); + tarefa.Status = (StatusTarefa)x.Field("Status"); + tarefa.Usuario = (x.Field("IdUsuario") != null ? Auxiliar.Usuarios.Find((Usuario u) => u.Id == x.Field("IdUsuario")) : null); + tarefa.UsuarioCadastro = (x.Field("IdUsuarioCadastro") != null ? Auxiliar.Usuarios.Find((Usuario u) => u.Id == x.Field("IdUsuarioCadastro")) : null); + tarefa.TipoDeTarefa = (x.Field("IdTipoTarefa") != null ? Auxiliar.TiposTarefa.Find((TipoDeTarefa t) => t.Id == x.Field("IdTipoTarefa")) : null); + tarefa.Restrito = new bool?(x.Field("Restrito").GetValueOrDefault()); + tarefa.Categoria = (x.Field("IdCategoria") != null ? Auxiliar.CategoriaTarefa.Find((CategoriaTarefa c) => c.Id == x.Field("IdCategoria")) : null); + EnumerableRowCollection dataRows = responsaveis.AsEnumerable().Where((DataRow r) => r.Field("IdTarefa") == x.Field("Id")); + Func u003cu003e9_46 = CustomMap.u003cu003ec.u003cu003e9__4_6; + if (u003cu003e9_46 == null) + { + u003cu003e9_46 = (DataRow r) => new ResponsavelTarefa() + { + Id = r.Field("Id"), + Usuario = Auxiliar.Usuarios.Find((Usuario u) => u.Id == r.Field("Usuario_id")) + }; + CustomMap.u003cu003ec.u003cu003e9__4_6 = u003cu003e9_46; + } + tarefa.Responsaveis = dataRows.Select(u003cu003e9_46).ToList(); + return tarefa; + }).ToList(); + } + + public static List MapTelefone(DataTable data) + { + return data.AsEnumerable().Select((DataRow x) => { + string str; + string str1; + string str2; + ClienteTelefone clienteTelefone = new ClienteTelefone() + { + Id = x.Field("Id"), + Cliente = new Cliente() + { + Id = x.Field("IdCliente"), + Nome = x.Field("NomeCliente") + } + }; + string str3 = x.Field("Prefixo"); + if (str3 != null) + { + str = str3.Trim(); + } + else + { + str = null; + } + clienteTelefone.Prefixo = str; + string str4 = x.Field("Numero"); + if (str4 != null) + { + str1 = str4.Trim(); + } + else + { + str1 = null; + } + clienteTelefone.Numero = str1; + clienteTelefone.Tipo = new TipoTelefone?((TipoTelefone)int.Parse(x.Field("Tipo").ToString())); + string str5 = x.Field("Observacao"); + if (str5 != null) + { + str2 = str5.Trim(); + } + else + { + str2 = null; + } + clienteTelefone.Observacao = str2; + clienteTelefone.Ordem = x.Field("Ordem"); + return clienteTelefone; + }).ToList(); + } + + public static List MapUsuario(DataTable data) + { + return data.AsEnumerable().ToList().Select((DataRow x) => { + TipoTelefone? nullable; + TipoTelefone? nullable1; + TipoTelefone? nullable2; + Usuario usuario = new Usuario() + { + IdEmpresa = x.Field("idempresa"), + Id = x.Field("idusuario"), + Nome = x.Field("nome"), + Login = x.Field("identif"), + Senha = x.Field("senha"), + Documento = x.Field("cgccpf"), + Nascimento = x.Field("dtnasc") + }; + bool? nullable3 = x.Field("removido"); + usuario.Excluido = nullable3.GetValueOrDefault(); + usuario.PermissaoAggilizador = x.Field("IdPermissao"); + nullable3 = x.Field("AdmGestor"); + usuario.Administrador = nullable3.GetValueOrDefault(); + nullable3 = x.Field("Segunda"); + usuario.Segunda = new bool?(nullable3.GetValueOrDefault(true)); + nullable3 = x.Field("Terca"); + usuario.Terca = new bool?(nullable3.GetValueOrDefault(true)); + nullable3 = x.Field("Quarta"); + usuario.Quarta = new bool?(nullable3.GetValueOrDefault(true)); + nullable3 = x.Field("Quinta"); + usuario.Quinta = new bool?(nullable3.GetValueOrDefault(true)); + nullable3 = x.Field("Sexta"); + usuario.Sexta = new bool?(nullable3.GetValueOrDefault(true)); + nullable3 = x.Field("Sabado"); + usuario.Sabado = new bool?(nullable3.GetValueOrDefault(true)); + nullable3 = x.Field("Domingo"); + usuario.Domingo = new bool?(nullable3.GetValueOrDefault(true)); + usuario.TelaInicial = new TipoTelaInicial?((x.Field("TelaInicial") == null ? TipoTelaInicial.Consulta : x.Field("TelaInicial"))); + usuario.Visita = x.Field("Visita"); + usuario.Cep = x.Field("cep"); + usuario.Endereco = x.Field("endereco"); + usuario.Numero = x.Field("numero"); + usuario.Complemento = x.Field("complemento"); + usuario.Bairro = x.Field("bairro"); + usuario.Cidade = x.Field("cidade"); + usuario.Estado = x.Field("uf"); + if (x.Field("TipoTelefone") == null) + { + nullable = null; + nullable1 = nullable; + } + else + { + nullable1 = new TipoTelefone?((TipoTelefone)x.Field("TipoTelefone")); + } + usuario.TipoTelefone = nullable1; + usuario.Prefixo = x.Field("ddd"); + usuario.Telefone = x.Field("telefone"); + if (x.Field("TipoTelefone2") == null) + { + nullable = null; + nullable2 = nullable; + } + else + { + nullable2 = new TipoTelefone?((TipoTelefone)x.Field("TipoTelefone2")); + } + usuario.TipoTelefone2 = nullable2; + usuario.Prefixo2 = x.Field("ddd2"); + usuario.Telefone2 = x.Field("telefone2"); + usuario.Email = x.Field("email"); + usuario.Identidade = x.Field("rg"); + usuario.EstadoEmissor = x.Field("rguf"); + usuario.Expedicao = x.Field("rgexpedicao"); + usuario.Agencia = x.Field("agencia"); + usuario.Conta = x.Field("conta"); + usuario.Mobile = (x.Field("mobile") == null ? false : x.Field("mobile").ToString() == "1"); + usuario.Resultados = (x.Field("acessoresult") == null ? false : x.Field("acessoresult").ToString() == "1"); + usuario.InicioAcesso = x.Field("InicioAcesso"); + usuario.FimAcesso = x.Field("FimAcesso"); + usuario.Cargo = x.Field("Cargo"); + usuario.FiltroInicial = new TipoFiltroCliente?((x.Field("FiltroInicial") == null ? TipoFiltroCliente.NomeSobrenome : x.Field("FiltroInicial"))); + nullable3 = x.Field("Dashboard"); + usuario.Dashboard = new bool?(nullable3.GetValueOrDefault(true)); + usuario.Banco = (x.Field("idcodigobanco") == null || !(x.Field("idcodigobanco").ToString() != "") ? null : Auxiliar.Banco.Find((Banco b) => (long)b.Id == long.Parse(x.Field("idcodigobanco").ToString()))); + usuario.Sexo = (x.Field("sexo") == null || !(x.Field("sexo").ToString() != "") ? Sexo.Masculino : int.Parse(x.Field("sexo").ToString())); + usuario.AdministradorCentralSegurado = (x.Field("AdmCentralSegurado") == null ? false : x.Field("AdmCentralSegurado")); + usuario.SsoId = x.Field("SsoId"); + return usuario; + }).ToList(); + } + + internal static List MapVendedor(this DataTable data) + { + return data.AsEnumerable().Select((DataRow x) => new Vendedor() + { + IdEmpresa = x.Field("idempresa").GetValueOrDefault((long)1), + Id = x.Field("idvendedor"), + Nome = x.Field("nome"), + Ativo = (x.Field("ativo") == null ? true : x.Field("ativo").ToString() == "1"), + Corretora = (x.Field("corretora") == null ? false : x.Field("corretora") == "1"), + TipoIncidenciaDesconto = (x.Field("tipoincidenciadesconto") == null ? TipoIncidenciaDesconto.Ambos : x.Field("tipoincidenciadesconto")), + Desconto = new decimal?((x.Field("desconto") == null ? decimal.Zero : x.Field("desconto") * new decimal(100, 0, 0, false, 2))), + Banco = (x.Field("idcodigobanco") == null ? null : Auxiliar.Banco.Find((Banco p) => p.Id == x.Field("idcodigobanco"))), + Agencia = x.Field("agencia"), + Conta = x.Field("conta"), + Documento = x.Field("cpfcnpj"), + TipoConta = (x.Field("idtipoconta") != null ? (Gestor.Model.Common.TipoConta)Enum.Parse(typeof(Gestor.Model.Common.TipoConta), x.Field("idtipoconta").ToString()) : Gestor.Model.Common.TipoConta.Nenhum), + TitularDocumento = x.Field("cpfcnpjtitular"), + TitularConta = x.Field("titularconta"), + Observacao = (x.Field("obs") == null ? "" : x.Field("obs").ToString()) + }).ToList(); + } + + internal static List MapVendedorParcela(DataTable data) + { + return data.AsEnumerable().Select((DataRow x) => { + VendedorParcela vendedorParcela = new VendedorParcela() + { + Id = x.Field("idvendedorparcela"), + Vendedor = Auxiliar.Vendedores.Find((Vendedor v) => v.Id == x.Field("idvendedor")), + Documento = new Documento() + { + Id = x.Field("iddocumento") + }, + Parcela = x.MapParcela(), + Repasse = (x.Field("idrepasse").HasValue ? Auxiliar.Repasses.Find((Repasse v) => v.Id == x.Field("idrepasse")) : null), + TipoVendedor = Auxiliar.TipoVendedores.Find((TipoVendedor v) => v.Id == x.Field("idtipovendedor")) + }; + decimal? nullable = x.Field("vlrrep"); + vendedorParcela.ValorRepasse = new decimal?(nullable.GetValueOrDefault()); + nullable = x.Field("vrep"); + vendedorParcela.PorcentagemRepasse = new decimal?(nullable.GetValueOrDefault()); + vendedorParcela.DataPrePagamento = x.Field("dataprepagto"); + vendedorParcela.DataPagamento = x.Field("datapgt"); + vendedorParcela.ValorTotal = x.Field("valortotal"); + vendedorParcela.CoCorretagem = x.Field("cocorretagem").GetValueOrDefault(); + return vendedorParcela; + }).ToList(); + } + + public static Usuario ToUsuario(this UserSso userSso, long idEmpresa) + { + return new Usuario() + { + SsoId = userSso.Id, + IdEmpresa = idEmpresa, + Nome = userSso.Name, + Login = userSso.Username, + Senha = userSso.Password, + Administrador = false, + Excluido = userSso.IsDeleted, + PermissaoAggilizador = new long?((long)1) + }; + } + } +} \ No newline at end of file -- cgit v1.2.3