2018-05-15 01:34:37 +02:00
|
|
|
|
using System.Linq;
|
2021-05-13 14:04:18 +02:00
|
|
|
|
using Sieve.Sample.Entities;
|
2018-05-15 01:34:37 +02:00
|
|
|
|
using Sieve.Services;
|
2018-01-27 07:37:38 +01:00
|
|
|
|
|
2021-05-13 14:04:18 +02:00
|
|
|
|
namespace Sieve.Sample.Services
|
2018-01-27 07:37:38 +01:00
|
|
|
|
{
|
2018-02-07 05:43:09 +01:00
|
|
|
|
public class SieveCustomSortMethods : ISieveCustomSortMethods
|
2018-01-27 07:37:38 +01:00
|
|
|
|
{
|
2018-05-15 01:34:37 +02:00
|
|
|
|
public IQueryable<Post> Popularity(IQueryable<Post> source, bool useThenBy) => useThenBy
|
|
|
|
|
? ((IOrderedQueryable<Post>)source).ThenBy(p => p.LikeCount)
|
|
|
|
|
: source.OrderBy(p => p.LikeCount)
|
2018-01-27 07:37:38 +01:00
|
|
|
|
.ThenBy(p => p.CommentCount)
|
|
|
|
|
.ThenBy(p => p.DateCreated);
|
|
|
|
|
}
|
|
|
|
|
}
|