Fix for Issue #19

This commit is contained in:
David Bond
2018-05-15 00:34:37 +01:00
parent afbd41e090
commit 204a1b55e2
39 changed files with 379 additions and 504 deletions

View File

@@ -2,14 +2,10 @@
using Sieve.Models;
using Sieve.Services;
using SieveTests.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace SieveTests.Services
{
public class ApplicationSieveProcessor : SieveProcessor
public class ApplicationSieveProcessor : SieveProcessor
{
public ApplicationSieveProcessor(IOptions<SieveOptions> options, ISieveCustomSortMethods customSortMethods, ISieveCustomFilterMethods customFilterMethods) : base(options, customSortMethods, customFilterMethods)
{

View File

@@ -1,20 +1,12 @@
using Sieve.Services;
using SieveTests.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace SieveTests.Services
{
public class SieveCustomFilterMethods : ISieveCustomFilterMethods
public class SieveCustomFilterMethods : ISieveCustomFilterMethods
{
public IQueryable<Post> IsNew(IQueryable<Post> source, string op, string value)
{
var result = source.Where(p => p.LikeCount < 100 &&
p.CommentCount < 5);
return result;
}
public IQueryable<Post> IsNew(IQueryable<Post> source)
=> source.Where(p => p.LikeCount < 100 && p.CommentCount < 5);
}
}

View File

@@ -1,23 +1,15 @@
using Sieve.Services;
using System.Linq;
using Sieve.Services;
using SieveTests.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace SieveTests.Services
{
public class SieveCustomSortMethods : ISieveCustomSortMethods
{
public IQueryable<Post> Popularity(IQueryable<Post> source, bool useThenBy, bool desc)
{
var result = useThenBy ?
((IOrderedQueryable<Post>)source).ThenBy(p => p.LikeCount) :
source.OrderBy(p => p.LikeCount)
public IQueryable<Post> Popularity(IQueryable<Post> source, bool useThenBy) => useThenBy
? ((IOrderedQueryable<Post>)source).ThenBy(p => p.LikeCount)
: source.OrderBy(p => p.LikeCount)
.ThenBy(p => p.CommentCount)
.ThenBy(p => p.DateCreated);
return result;
}
}
}