Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Brunobento1990 committed Dec 28, 2024
1 parent a4c841e commit 8ee3d58
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
8 changes: 8 additions & 0 deletions OpenAdm.Application/Services/ProdutoService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,14 @@ public async Task<PaginacaoViewModel<ProdutoViewModel>> GetPaginacaoAsync(Pagina
{
var paginacao = await _produtoRepository.PaginacaoAsync(paginacaoProdutoDto);

foreach (var produto in paginacao.Values)
{
if (produto.Categoria != null)
{
produto.Categoria.Produtos = [];
}
}

return new PaginacaoViewModel<ProdutoViewModel>()
{
TotalDeRegistros = paginacao.TotalDeRegistros,
Expand Down
9 changes: 8 additions & 1 deletion OpenAdm.Infra/Paginacao/PaginacaoProdutoDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ public class PaginacaoProdutoDto : FilterModel<Produto>
if (string.IsNullOrWhiteSpace(Search))
return null;

return x => EF.Functions.ILike(EF.Functions.Unaccent(x.Descricao), $"%{Search}%");
var pesquisa = Search.ToLower();
return x => EF.Functions.ILike(EF.Functions.Unaccent(x.Descricao.ToLower()), $"%{pesquisa}%")
|| EF.Functions.ILike(EF.Functions.Unaccent(x.Categoria.Descricao.ToLower()), $"%{pesquisa}%");
}

public override Expression<Func<Produto, object>>? IncludeCustom()
{
return x => x.Categoria;
}
}

0 comments on commit 8ee3d58

Please sign in to comment.