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 --- .../AutoRepository.cs | 607 --------------------- 1 file changed, 607 deletions(-) delete mode 100644 Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/AutoRepository.cs (limited to 'Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/AutoRepository.cs') diff --git a/Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/AutoRepository.cs b/Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/AutoRepository.cs deleted file mode 100644 index 7cbb775..0000000 --- a/Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/AutoRepository.cs +++ /dev/null @@ -1,607 +0,0 @@ -using AutoMapper; -using Gestor.Infrastructure.Entities.Generic; -using Gestor.Infrastructure.Entities.Seguros; -using Gestor.Infrastructure.Helpers; -using Gestor.Infrastructure.Mappers; -using Gestor.Infrastructure.Repository.Generic; -using Gestor.Infrastructure.Repository.Interface; -using Gestor.Infrastructure.UnitOfWork.Generic; -using Gestor.Model.Common; -using Gestor.Model.Domain.Common; -using Gestor.Model.Domain.Generic; -using Gestor.Model.Domain.Seguros; -using NHibernate; -using NHibernate.Connection; -using NHibernate.Impl; -using System; -using System.Collections.Generic; -using System.Data; -using System.Data.Common; -using System.Data.SqlClient; -using System.Linq; -using System.Linq.Expressions; -using System.Runtime.CompilerServices; - -namespace Gestor.Infrastructure.Repository.Logic -{ - public class AutoRepository : GenericRepository, IAutoRepository, IGenericRepository - { - private readonly GenericUnitOfWork _unitOfWork; - - public AutoRepository(GenericUnitOfWork unitOfWork) : base(unitOfWork.Session) - { - this._unitOfWork = unitOfWork; - } - - public void Delete(long id) - { - AutoDb autoDb = base.FindEntityById(id); - if (autoDb == null) - { - return; - } - base.Delete(autoDb); - } - - public void DeleteRange(List ids) - { - List list = ( - from x in base.All() - where ids.Contains(x.Item.Id) - select x).ToList(); - base.DeleteRange(list); - } - - public Auto Find(long id) - { - AutoDb autoDb = base.All().FirstOrDefault((AutoDb x) => x.Item.Id == id) ?? new AutoDb(); - return ApplicationMapper.Mapper.Map(autoDb); - } - - public List FindAuto(string pesquisa, FiltroStatusDocumento status, List vendedorVinculado, TipoPesquisa tipo, bool tipobusca = false) - { - List pesquisaAvancadas; - object connection; - DataTable dataTable = new DataTable(); - DataTable dataTable1 = new DataTable(); - DataTable dataTable2 = new DataTable(); - DataTable dataTable3 = new DataTable(); - DateTime date = Funcoes.GetNetworkTime().Date; - List condicaos = new List() - { - new Condicao() - { - Campo = "d.excluido", - Valores = null, - Grupo = 1, - Operacao = Operacao.Or - }, - new Condicao() - { - Campo = "d.excluido", - Valores = "0".CriarValor(), - Grupo = 1, - Operacao = Operacao.Or - } - }; - switch (status) - { - case FiltroStatusDocumento.Vencidos: - { - condicaos.AddRange(new List() - { - new Condicao() - { - Campo = "d.situacao", - Valores = new List() - { - 3, - 7 - }, - Operador = Operador.Diferente - }, - new Condicao() - { - Campo = "d.vigencia2", - Valores = date.AddDays(-5).CriarValor(), - Operador = Operador.Menor - } - }); - goto case FiltroStatusDocumento.Todos; - } - case FiltroStatusDocumento.Cancelados: - { - condicaos.Add(new Condicao() - { - Campo = "d.situacao", - Valores = 3.CriarValor() - }); - goto case FiltroStatusDocumento.Todos; - } - case FiltroStatusDocumento.Recusados: - { - condicaos.Add(new Condicao() - { - Campo = "d.situacao", - Valores = 7.CriarValor() - }); - goto case FiltroStatusDocumento.Todos; - } - case FiltroStatusDocumento.Todos: - { - SessionFactoryImpl sessionFactory = this._unitOfWork.Session.SessionFactory as SessionFactoryImpl; - if (sessionFactory != null) - { - connection = sessionFactory.ConnectionProvider.GetConnection(); - } - else - { - connection = null; - } - using (SqlConnection sqlConnection = connection as SqlConnection) - { - using (SqlCommand sqlCommand = sqlConnection.CreateCommand()) - { - List condicaos1 = new List(); - if (tipo == TipoPesquisa.Chassi) - { - condicaos1.Add(new Condicao() - { - Campo = "a.chassi", - Valores = pesquisa.CriarValor(), - Operador = (tipobusca ? Operador.Igual : Operador.Like) - }); - } - else if (tipo == TipoPesquisa.Item) - { - condicaos1.Add(new Condicao() - { - Campo = "i.descricao", - Valores = pesquisa.CriarValor(), - Operador = (tipobusca ? Operador.Igual : Operador.Like) - }); - } - else if (tipo == TipoPesquisa.Placa) - { - condicaos1.Add(new Condicao() - { - Campo = "REPLACE(a.placa, '-','')", - Valores = pesquisa.Replace("-", "").Replace("?", "%").CriarValor(), - Operador = (tipobusca ? Operador.Igual : Operador.Like) - }); - } - dataTable = sqlCommand.Select(condicaos1.CreateParameters(0), "SELECT TOP 1000 i.iditem as id FROM item i LEFT OUTER JOIN auto a on i.iditem = a.iditem WHERE ", ""); - if (dataTable.Rows.Count != 0) - { - List condicaos2 = new List() - { - new Condicao() - { - Campo = "iditem", - Valores = dataTable.AsEnumerable().Select((DataRow v) => v.Field("id")).ToList().CriarValor() - } - }; - dataTable1 = sqlCommand.Select(condicaos2.CreateParameters(0), "SELECT iddocumento as id, descricao, iditem FROM item WHERE", ""); - condicaos.Add(new Condicao() - { - Campo = "d.iddocumento", - Valores = dataTable1.AsEnumerable().Select((DataRow v) => v.Field("id")).ToList().CriarValor() - }); - dataTable2 = sqlCommand.Select(condicaos.CreateParameters(0), "SELECT DISTINCT cl.nome as cliente, c.idcliente, d.idcontrole, d.iddocumento, situacao, ISNULL(vigencia1, GETDATE()) AS vigencia1, vigencia2, proposta, contrato as apolice, aditamento as endosso, CAST(tipo as INTEGER) as tipo FROM documento d INNER JOIN controle c on c.idcontrole = d.idcontrole INNER JOIN cliente cl on cl.idcliente = c.idcliente WHERE ", ""); - if (dataTable2.Rows.Count != 0) - { - List list = ( - from x in dataTable2.AsEnumerable().ToList() - select x.Field("idcontrole")).ToList(); - List condicaos3 = new List() - { - new Condicao() - { - Campo = "d.idcontrole", - Valores = list.CriarValor() - } - }; - dataTable3 = sqlCommand.Select(condicaos3.CreateParameters(0), "SELECT DISTINCT vp.idvendedor, d.iddocumento, d.idcontrole, vp.idtipovendedor FROM vendedorparcela vp INNER JOIN documento d on d.iddocumento = vp.iddocumento WHERE ", ""); - goto Label1; - } - else - { - pesquisaAvancadas = new List(); - } - } - else - { - pesquisaAvancadas = new List(); - } - } - } - return pesquisaAvancadas; - } - default: - { - condicaos.AddRange(new List() - { - new Condicao() - { - Campo = "d.situacao", - Valores = new List() - { - 1, - 2, - 4 - } - }, - new Condicao() - { - Campo = "d.vigencia2", - Valores = null, - Grupo = 2, - Operacao = Operacao.Or - }, - new Condicao() - { - Campo = "d.vigencia2", - Valores = date.AddDays(-5).CriarValor(), - Grupo = 2, - Operacao = Operacao.Or, - Operador = Operador.Maior - } - }); - goto case FiltroStatusDocumento.Todos; - } - } - Label1: - List nums = null; - if (vendedorVinculado != null && vendedorVinculado.Count > 0) - { - nums = dataTable3.AsEnumerable().Where((DataRow x) => { - List vendedorUsuarios = vendedorVinculado; - Func u003cu003e9_107 = AutoRepository.u003cu003ec.u003cu003e9__10_7; - if (u003cu003e9_107 == null) - { - u003cu003e9_107 = (VendedorUsuario v) => v.Vendedor.Id; - AutoRepository.u003cu003ec.u003cu003e9__10_7 = u003cu003e9_107; - } - return vendedorUsuarios.Select(u003cu003e9_107).Contains(x.Field("idvendedor")); - }).Select((DataRow x) => x.Field("idcontrole")).ToList(); - } - if (nums != null && nums.Count == 0) - { - return new List(); - } - return dataTable2.AsEnumerable().Where((DataRow x) => { - if (nums == null) - { - return true; - } - return nums.Contains(x.Field("idcontrole")); - }).Select((DataRow x) => new PesquisaAvancada() - { - IdCliente = x.Field("idcliente"), - IdDocumento = x.Field("iddocumento"), - IdItem = dataTable1.AsEnumerable().First((DataRow i) => i.Field("id") == x.Field("iddocumento")).Field("iditem"), - Nome = x.Field("cliente"), - Pesquisa = (x.Field("tipo") == 0 ? string.Format("ITEM: {0} - NÚMERO DA APÓLICE: {1} - NÚMERO DA PROPOSTA: {2} - VIGÊNCIA INICIAL: {3:d} ", new object[] { dataTable1.AsEnumerable().First((DataRow i) => i.Field("id") == x.Field("iddocumento")).Field("descricao"), x.Field("apolice"), x.Field("proposta"), x.Field("vigencia1") }) : string.Format("ITEM: {0} - NÚMERO DA APÓLICE: {1} - NÚMERO DA PROPOSTA: {2} - NÚMERO DO ENDOSSO: {3} VIGÊNCIA INICIAL: {4:d}", new object[] { dataTable1.AsEnumerable().First((DataRow i) => i.Field("id") == x.Field("iddocumento")).Field("descricao"), x.Field("apolice"), x.Field("proposta"), x.Field("endosso"), x.Field("vigencia1") })) - }).ToList(); - } - - public Documento FindByChassi(string chassi, long id, DateTime vigencia1, DateTime? vigencia2, long idSeguradora) - { - DocumentoDb documento; - List tipoSeguros = new List() - { - TipoSeguro.Novo, - TipoSeguro.Renovacao, - TipoSeguro.Reabilitado - }; - DateTime dateTime3 = Convert.ToDateTime(vigencia2); - AutoDb autoDb = ( - from a in base.All() - select new AutoDb() - { - Id = a.Id, - Chassi = a.Chassi, - Item = new ItemDb() - { - Cancelado = a.Item.Cancelado, - Substituido = a.Item.Substituido, - Documento = new DocumentoDb() - { - Vigencia1 = a.Item.Documento.Vigencia1, - Vigencia2 = a.Item.Documento.Vigencia2, - Situacao = a.Item.Documento.Situacao, - Excluido = a.Item.Documento.Excluido, - Controle = new ControleDb() - { - Id = a.Item.Documento.Controle.Id, - Seguradora = new SeguradoraDb() - { - Id = a.Item.Documento.Controle.Seguradora.Id, - Nome = a.Item.Documento.Controle.Seguradora.Nome, - NomeSocial = a.Item.Documento.Controle.Seguradora.NomeSocial - }, - Cliente = new ClienteDb() - { - Id = a.Item.Documento.Controle.Cliente.Id, - Nome = a.Item.Documento.Controle.Cliente.Nome - } - } - } - } - } into x - where x.Id != id && x.Chassi == chassi && tipoSeguros.Contains(x.Item.Documento.Situacao) - select x).ToList().AsEnumerable().ToList().Where((AutoDb x) => { - DateTime dateTime = dateTime3; - DateTime dateTime4 = x.Item.Documento.Vigencia1; - if (dateTime >= dateTime4.AddDays(5)) - { - DateTime dateTime1 = dateTime3; - dateTime4 = Convert.ToDateTime(x.Item.Documento.Vigencia2); - if (dateTime1 <= dateTime4.AddDays(5)) - { - return true; - } - } - DateTime dateTime2 = vigencia1; - dateTime4 = x.Item.Documento.Vigencia1; - if (dateTime2 < dateTime4.AddDays(5)) - { - return false; - } - dateTime4 = vigencia1.AddDays(5); - DateTime? nullable1 = x.Item.Documento.Vigencia2; - if (!nullable1.HasValue) - { - return false; - } - return dateTime4 <= nullable1.GetValueOrDefault(); - }).ToList().FirstOrDefault((AutoDb x) => { - long? nullable; - if (!x.Item.Cancelado) - { - long? substituido = x.Item.Substituido; - if (!substituido.HasValue && !x.Item.Documento.Excluido) - { - long num = idSeguradora; - ControleDb controle = x.Item.Documento.Controle; - if (controle != null) - { - nullable = new long?(controle.Seguradora.Id); - } - else - { - nullable = null; - } - substituido = nullable; - return num == substituido.GetValueOrDefault() & substituido.HasValue; - } - } - return false; - }); - if (autoDb != null) - { - documento = autoDb.Item.Documento; - } - else - { - documento = null; - } - return ApplicationMapper.Mapper.Map(documento); - } - - public Auto FindById(long id) - { - AutoDb autoDb = base.FindEntityById(id); - return ApplicationMapper.Mapper.Map(autoDb); - } - - public string FindChassi(long id) - { - List condicaos = new List() - { - new Condicao() - { - Campo = "iditem", - Valores = id.CriarValor() - } - }; - DataTable dataTable = this._unitOfWork.Select(condicaos.CreateParameters(0), "SELECT chassi FROM auto WHERE ", ""); - if (dataTable == null) - { - return null; - } - DataRow dataRow = dataTable.AsEnumerable().FirstOrDefault(); - if (dataRow == null) - { - return null; - } - return dataRow.Field("chassi"); - } - - public List FindPlaca(string placa, FiltroStatusDocumento status, List vendedorVinculado) - { - List pesquisaAvancadas; - object connection; - string str = placa.Replace("-", ""); - string str1 = str.Insert(3, "-"); - DataTable dataTable = new DataTable(); - DataTable dataTable1 = new DataTable(); - DataTable dataTable2 = new DataTable(); - DataTable dataTable3 = new DataTable(); - SessionFactoryImpl sessionFactory = this._unitOfWork.Session.SessionFactory as SessionFactoryImpl; - if (sessionFactory != null) - { - connection = sessionFactory.ConnectionProvider.GetConnection(); - } - else - { - connection = null; - } - using (SqlConnection sqlConnection = connection as SqlConnection) - { - using (SqlCommand sqlCommand = sqlConnection.CreateCommand()) - { - sqlCommand.CommandText = string.Concat(new string[] { "SELECT iditem as id FROM auto WHERE placa ='", str, "' OR placa ='", str1, "'" }); - using (SqlDataAdapter sqlDataAdapter = new SqlDataAdapter()) - { - sqlDataAdapter.SelectCommand = sqlCommand; - sqlDataAdapter.Fill(dataTable); - } - if (dataTable.Rows.Count != 0) - { - string str2 = string.Concat(" AND iditem IN (", string.Join(",", dataTable.AsEnumerable().Select((DataRow v) => v.Field("id"))), ")"); - sqlCommand.CommandText = string.Concat("SELECT iddocumento as id, descricao, iditem FROM item WHERE 1=1 ", str2); - using (SqlDataAdapter sqlDataAdapter1 = new SqlDataAdapter()) - { - sqlDataAdapter1.SelectCommand = sqlCommand; - sqlDataAdapter1.Fill(dataTable1); - } - sqlCommand.CommandText = string.Concat("SELECT DISTINCT cl.nome as cliente, c.idcliente, d.idcontrole, d.iddocumento, situacao, vigencia1, vigencia2, proposta, contrato as apolice, aditamento as endosso, CAST(tipo as INTEGER) as tipo FROM documento d INNER JOIN controle c on c.idcontrole = d.idcontrole INNER JOIN cliente cl on cl.idcliente = c.idcliente WHERE (d.excluido IS NULL OR d.excluido != '1') AND d.iddocumento IN (", string.Join(",", dataTable1.AsEnumerable().Select((DataRow v) => v.Field("id"))), ")"); - using (SqlDataAdapter sqlDataAdapter2 = new SqlDataAdapter()) - { - sqlDataAdapter2.SelectCommand = sqlCommand; - sqlDataAdapter2.Fill(dataTable2); - } - string str3 = string.Concat(" AND d.idcontrole IN (", string.Join(",", ( - from x in dataTable2.AsEnumerable().ToList() - select x.Field("idcontrole")).ToList()), ")"); - sqlCommand.CommandText = string.Concat("SELECT DISTINCT vp.idvendedor, d.iddocumento, d.idcontrole, vp.idtipovendedor FROM vendedorparcela vp INNER JOIN documento d on d.iddocumento = vp.iddocumento WHERE 1=1 ", str3); - using (SqlDataAdapter sqlDataAdapter3 = new SqlDataAdapter()) - { - sqlDataAdapter3.SelectCommand = sqlCommand; - sqlDataAdapter3.Fill(dataTable3); - goto Label0; - } - } - else - { - pesquisaAvancadas = new List(); - } - } - } - return pesquisaAvancadas; - Label0: - List list = null; - if (vendedorVinculado != null && vendedorVinculado.Count > 0) - { - list = dataTable3.AsEnumerable().Where((DataRow x) => { - List vendedorUsuarios = vendedorVinculado; - Func u003cu003e9_915 = AutoRepository.u003cu003ec.u003cu003e9__9_15; - if (u003cu003e9_915 == null) - { - u003cu003e9_915 = (VendedorUsuario v) => v.Vendedor.Id; - AutoRepository.u003cu003ec.u003cu003e9__9_15 = u003cu003e9_915; - } - return vendedorUsuarios.Select(u003cu003e9_915).Contains(x.Field("idvendedor")); - }).Select((DataRow x) => x.Field("idcontrole")).ToList(); - } - if (list != null && list.Count == 0) - { - return new List(); - } - DateTime date = Funcoes.GetNetworkTime().Date; - switch (status) - { - case FiltroStatusDocumento.Vencidos: - { - return dataTable2.AsEnumerable().Where((DataRow x) => { - if ((list == null || list.Contains(x.Field("idcontrole"))) && (TipoSeguro)Enum.Parse(typeof(TipoSeguro), x.Field("situacao").ToString()) == TipoSeguro.Renovado) - { - return true; - } - return x.Field("vigencia2") < date.AddDays(-5); - }).Select((DataRow x) => new PesquisaAvancada() - { - IdCliente = x.Field("idcliente"), - IdDocumento = x.Field("iddocumento"), - IdItem = dataTable1.AsEnumerable().First((DataRow i) => i.Field("id") == x.Field("iddocumento")).Field("iditem"), - Nome = x.Field("cliente"), - Pesquisa = (x.Field("tipo") == 0 ? string.Concat(new string[] { "ITEM: ", dataTable1.AsEnumerable().First((DataRow i) => i.Field("id") == x.Field("iddocumento")).Field("descricao"), " - NÚMERO DA APÓLICE: ", x.Field("apolice"), " - NÚMERO DA PROPOSTA: ", x.Field("proposta") }) : string.Concat(new string[] { "ITEM: ", dataTable1.AsEnumerable().First((DataRow i) => i.Field("id") == x.Field("iddocumento")).Field("descricao"), " - NÚMERO DA APÓLICE: ", x.Field("apolice"), " - NÚMERO DA PROPOSTA: ", x.Field("proposta"), " - NÚMERO DO ENDOSSO: ", x.Field("endosso") })) - }).ToList(); - } - case FiltroStatusDocumento.Cancelados: - { - return dataTable2.AsEnumerable().Where((DataRow x) => { - if (list != null && !list.Contains(x.Field("idcontrole"))) - { - return false; - } - return (TipoSeguro)Enum.Parse(typeof(TipoSeguro), x.Field("situacao").ToString()) == TipoSeguro.Cancelado; - }).Select((DataRow x) => new PesquisaAvancada() - { - IdCliente = x.Field("idcliente"), - IdDocumento = x.Field("iddocumento"), - IdItem = dataTable1.AsEnumerable().First((DataRow i) => i.Field("id") == x.Field("iddocumento")).Field("iditem"), - Nome = x.Field("cliente"), - Pesquisa = (x.Field("tipo") == 0 ? string.Concat(new string[] { "ITEM: ", dataTable1.AsEnumerable().First((DataRow i) => i.Field("id") == x.Field("iddocumento")).Field("descricao"), " - NÚMERO DA APÓLICE: ", x.Field("apolice"), " - NÚMERO DA PROPOSTA: ", x.Field("proposta") }) : string.Concat(new string[] { "ITEM: ", dataTable1.AsEnumerable().First((DataRow i) => i.Field("id") == x.Field("iddocumento")).Field("descricao"), " - NÚMERO DA APÓLICE: ", x.Field("apolice"), " - NÚMERO DA PROPOSTA: ", x.Field("proposta"), " - NÚMERO DO ENDOSSO: ", x.Field("endosso") })) - }).ToList(); - } - case FiltroStatusDocumento.Recusados: - { - return dataTable2.AsEnumerable().Where((DataRow x) => { - if (list != null && !list.Contains(x.Field("idcontrole"))) - { - return false; - } - return (TipoSeguro)Enum.Parse(typeof(TipoSeguro), x.Field("situacao").ToString()) == TipoSeguro.Recusado; - }).Select((DataRow x) => new PesquisaAvancada() - { - IdCliente = x.Field("idcliente"), - IdDocumento = x.Field("iddocumento"), - IdItem = dataTable1.AsEnumerable().First((DataRow i) => i.Field("id") == x.Field("iddocumento")).Field("iditem"), - Nome = x.Field("cliente"), - Pesquisa = (x.Field("tipo") == 0 ? string.Concat(new string[] { "ITEM: ", dataTable1.AsEnumerable().First((DataRow i) => i.Field("id") == x.Field("iddocumento")).Field("descricao"), " - NÚMERO DA APÓLICE: ", x.Field("apolice"), " - NÚMERO DA PROPOSTA: ", x.Field("proposta") }) : string.Concat(new string[] { "ITEM: ", dataTable1.AsEnumerable().First((DataRow i) => i.Field("id") == x.Field("iddocumento")).Field("descricao"), " - NÚMERO DA APÓLICE: ", x.Field("apolice"), " - NÚMERO DA PROPOSTA: ", x.Field("proposta"), " - NÚMERO DO ENDOSSO: ", x.Field("endosso") })) - }).ToList(); - } - case FiltroStatusDocumento.Todos: - { - return dataTable2.AsEnumerable().Where((DataRow x) => { - if (list == null) - { - return true; - } - return list.Contains(x.Field("idcontrole")); - }).Select((DataRow x) => new PesquisaAvancada() - { - IdCliente = x.Field("idcliente"), - IdDocumento = x.Field("iddocumento"), - IdItem = dataTable1.AsEnumerable().First((DataRow i) => i.Field("id") == x.Field("iddocumento")).Field("iditem"), - Nome = x.Field("cliente"), - Pesquisa = (x.Field("tipo") == 0 ? string.Concat(new string[] { "ITEM: ", dataTable1.AsEnumerable().First((DataRow i) => i.Field("id") == x.Field("iddocumento")).Field("descricao"), " - NÚMERO DA APÓLICE: ", x.Field("apolice"), " - NÚMERO DA PROPOSTA: ", x.Field("proposta") }) : string.Concat(new string[] { "ITEM: ", dataTable1.AsEnumerable().First((DataRow i) => i.Field("id") == x.Field("iddocumento")).Field("descricao"), " - NÚMERO DA APÓLICE: ", x.Field("apolice"), " - NÚMERO DA PROPOSTA: ", x.Field("proposta"), " - NÚMERO DO ENDOSSO: ", x.Field("endosso") })) - }).ToList(); - } - default: - { - return dataTable2.AsEnumerable().Where((DataRow x) => { - if (list != null && !list.Contains(x.Field("idcontrole")) || (TipoSeguro)Enum.Parse(typeof(TipoSeguro), x.Field("situacao").ToString()) != TipoSeguro.Novo && (TipoSeguro)Enum.Parse(typeof(TipoSeguro), x.Field("situacao").ToString()) != TipoSeguro.Renovacao) - { - return false; - } - return x.Field("vigencia2") > date.AddDays(-5); - }).Select((DataRow x) => new PesquisaAvancada() - { - IdCliente = x.Field("idcliente"), - IdDocumento = x.Field("iddocumento"), - IdItem = dataTable1.AsEnumerable().First((DataRow i) => i.Field("id") == x.Field("iddocumento")).Field("iditem"), - Nome = x.Field("cliente"), - Pesquisa = (x.Field("tipo") == 0 ? string.Concat(new string[] { "ITEM: ", dataTable1.AsEnumerable().First((DataRow i) => i.Field("id") == x.Field("iddocumento")).Field("descricao"), " - NÚMERO DA APÓLICE: ", x.Field("apolice"), " - NÚMERO DA PROPOSTA: ", x.Field("proposta") }) : string.Concat(new string[] { "ITEM: ", dataTable1.AsEnumerable().First((DataRow i) => i.Field("id") == x.Field("iddocumento")).Field("descricao"), " - NÚMERO DA APÓLICE: ", x.Field("apolice"), " - NÚMERO DA PROPOSTA: ", x.Field("proposta"), " - NÚMERO DO ENDOSSO: ", x.Field("endosso") })) - }).ToList(); - } - } - } - - public Auto Merge(Auto auto) - { - AutoDb autoDb = ApplicationMapper.Mapper.Map(auto); - base.Merge(autoDb); - return ApplicationMapper.Mapper.Map(autoDb); - } - - public Auto SaveOrUpdate(Auto auto) - { - AutoDb autoDb = ApplicationMapper.Mapper.Map(auto); - this.SaveOrUpdate(autoDb); - return ApplicationMapper.Mapper.Map(autoDb); - } - } -} \ No newline at end of file -- cgit v1.2.3