Skip to content

Commit

Permalink
Refactored repository and fixed issue in InMemoryProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
linkdotnet committed Nov 18, 2021
1 parent 49dcf1b commit 740c4a9
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,12 @@ public Task<IPagedList<TEntity>> GetAllAsync(

if (orderBy != null)
{
if (descending)
{
return Task.FromResult(result.OrderByDescending(orderBy.Compile()).ToPagedList(page, pageSize));
}

return Task.FromResult(result.OrderBy(orderBy.Compile()).ToPagedList(page, pageSize));
result = descending
? result.OrderByDescending(orderBy.Compile())
: result.OrderBy(orderBy.Compile());
}

return Task.FromResult(entities.ToPagedList(page, pageSize));
return Task.FromResult(result.ToPagedList(page, pageSize));
}

public Task StoreAsync(TEntity entity)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,9 @@ public async Task<IPagedList<TEntity>> GetAllAsync(

if (orderBy != null)
{
if (descending)
{
return await query.OrderByDescending(orderBy).ToPagedListAsync(page, pageSize);
}

return await query.OrderBy(orderBy).ToPagedListAsync(page, pageSize);
query = descending
? query.OrderByDescending(orderBy)
: query.OrderBy(orderBy);
}

return await query.ToPagedListAsync(page, pageSize);
Expand Down
9 changes: 3 additions & 6 deletions LinkDotNet.Blog.Infrastructure/Persistence/Sql/Repository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,9 @@ public async Task<IPagedList<TEntity>> GetAllAsync(

if (orderBy != null)
{
if (descending)
{
return await entity.OrderByDescending(orderBy).ToPagedListAsync(page, pageSize);
}

return await entity.OrderBy(orderBy).ToPagedListAsync(page, pageSize);
entity = descending
? entity.OrderByDescending(orderBy)
: entity.OrderBy(orderBy);
}

return await entity.ToPagedListAsync(page, pageSize);
Expand Down
2 changes: 1 addition & 1 deletion LinkDotNet.Blog.Web/Shared/AccessControl.razor
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<li><h6 class="dropdown-header">Others</h6></li>
<li><a class="dropdown-item" href="Sitemap">Sitemap</a></li>
<li><hr class="dropdown-divider"></li>
<li><a class="dropdown-item" href="https://github.com/linkdotnet/Blog/releases">Version 2.5</a></li>
<li><a class="dropdown-item" href="https://github.com/linkdotnet/Blog/releases">Version 2.6</a></li>
</ul>
</li>
<li class="nav-item"><a class="nav-link" href="logout">Log out</a></li>
Expand Down

0 comments on commit 740c4a9

Please sign in to comment.