Ejemplo n.º 1
0
        public async Task <List <Bebida> > ObterBebidas(FiltrosBebida filtros)
        {
            string sql = "SELECT produtoId, nome, descricao, preco, foto, embalagem, tipo " +
                         "FROM Produtos WHERE tipo = 'bebida' ";

            var values = new DynamicParameters();

            if (!string.IsNullOrEmpty(filtros.descricao))
            {
                sql += " and descricao like @Descricao ";
                values.AddDynamicParams(new { Descricao = "%" + filtros.descricao + "%" });
            }

            if (!string.IsNullOrEmpty(filtros.nome))
            {
                sql += " and Nome like @Nome ";
                values.AddDynamicParams(new { Nome = "%" + filtros.nome + "%" });
            }

            if (!string.IsNullOrEmpty(filtros.embalagem))
            {
                sql += " and Embalagem like @Embalagem ";
                values.AddDynamicParams(new { Embalagem = "%" + filtros.embalagem + "%" });
            }

            sql += " ORDER BY nome";
            return((await Conexao.QueryAsync <Bebida>(sql, values)).ToList());
        }
Ejemplo n.º 2
0
 public async Task <IEnumerable <Bebida> > ObterBebidas([FromQuery] FiltrosBebida parameters)
 {
     return(await _produtos.ObterBebidas(parameters));
 }