Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed projects filter bug #199

Merged
merged 3 commits into from
Jun 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixed issue where users were able to delete some roles that were critical for the platform - [#178](https://github.com/DigitalExcellence/dex-backend/issues/178)
- Fixed role update endpoint returning internal server error - [#178](https://github.com/DigitalExcellence/dex-backend/issues/178)
- Fixed issue where the user was not returned on the /api/Project endpoint (which returns all the projects) - [#169](https://github.com/DigitalExcellence/dex-backend/issues/169)
- Fixed issue where the projects endpoint returned unexpected results when using filters - [#185](https://github.com/DigitalExcellence/dex-backend/issues/185)


### Security
24 changes: 12 additions & 12 deletions Repositories/ProjectRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,18 +133,6 @@ private IQueryable<Project> ApplyFilters(
bool? highlighted
)
{
if(orderBy != null)
{
if(orderByAsc)
{
queryable = queryable.OrderBy(orderBy);
} else
{
queryable = queryable.OrderByDescending(orderBy);
}
}
if(skip.HasValue) queryable = queryable.Skip(skip.Value);
if(take.HasValue) queryable = queryable.Take(take.Value);
if(highlighted.HasValue)
{
IEnumerable<int> highlightedQueryable = DbContext.Set<Highlight>()
Expand All @@ -162,6 +150,18 @@ private IQueryable<Project> ApplyFilters(
queryable = queryable.Where(p => !highlightedQueryable.Contains(p.Id));
}
}
if(orderBy != null)
{
if(orderByAsc)
{
queryable = queryable.OrderBy(orderBy);
} else
{
queryable = queryable.OrderByDescending(orderBy);
}
}
if(skip.HasValue) queryable = queryable.Skip(skip.Value);
if(take.HasValue) queryable = queryable.Take(take.Value);
return queryable;
}

Expand Down