public List <PropostaAgregate> PesquisarPropostas(PesquisaPropostaModel filtro)
        {
            string sql = @"select p.ID, p.Nome, p.IdFornecedor, p.IdCategoria, p.Data, p.Valor, p.Descricao, p.Status, p.Arquivo, p.Ativo
                                , c.ID, c.Nome, c.Descricao, c.Ativo
                                , f.ID, f.Nome, f.Documento, f.Telefone, f.Email, f.Ativo
                             from Proposta p(NOLOCK)
                                  join Categoria c(NOLOCK) on p.IdCategoria = c.ID
                                  join Fornecedor f(NOLOCK) on p.IdFornecedor = f.ID
                            where p.Ativo = 1
                              and (p.IdCategoria = @IdCategoria or @IdCategoria = 0)
                              and p.Status = @Status
                              and p.Data between @DataInicial and @DataFinal
                              and p.Nome like @NomeProposta
                              and f.Nome like @NomeFornecedor
                            order by p.Nome";

            List <PropostaAgregate> result = null;

            using (var con = db.CreateConnection())
            {
                con.Open();
                result = con.Query <PropostaAgregate, Categoria, Fornecedor, PropostaAgregate>(sql,
                                                                                               (proposta, categoria, fornecedor) =>
                {
                    proposta.Categoria  = categoria;
                    proposta.Fornecedor = fornecedor;
                    return(proposta);
                },
                                                                                               filtro).ToList();
                con.Close();
            }

            return(result);
        }
 public HttpResponseMessage PesquisarProposta([FromBody] PesquisaPropostaModel model)
 {
     return(ExecuteFunction(() =>
     {
         model.NomeProposta += "%";
         model.NomeFornecedor += "%";
         var result = service.Pesquisar(model);
         return Request.CreateResponse(HttpStatusCode.OK, result);
     }));
 }
Exemple #3
0
 public List <PropostaModel> Pesquisar(PesquisaPropostaModel model)
 {
     try
     {
         model.DataFinal = model.DataFinal.AddDays(1).AddSeconds(-1);
         return(_ado.PesquisarPropostas(model).ListTo <PropostaModel>());
     }
     catch (Exception ex)
     {
         LogUtil.Error(ex);
         throw;
     }
 }