This repository has been archived by the owner on Feb 6, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Filters and generic storage client for API #19
- Loading branch information
Showing
23 changed files
with
155 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace Coolector.Common.Types | ||
{ | ||
public interface IPagedQuery : IQuery | ||
{ | ||
int Page { get; } | ||
int Results { get; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,19 @@ | ||
using System.Collections.Generic; | ||
using Coolector.Common.DTO.Users; | ||
using Coolector.Common.Extensions; | ||
using Coolector.Common.Types; | ||
|
||
namespace Coolector.Core.Filters | ||
{ | ||
public class BrowseUsersFilter : IFilter<UserDto, BrowseUsers> | ||
{ | ||
public Maybe<PagedResult<UserDto>> Filter(Maybe<IEnumerable<UserDto>> values, BrowseUsers query) | ||
public Maybe<IEnumerable<UserDto>> Filter(Maybe<IEnumerable<UserDto>> values, BrowseUsers query) | ||
{ | ||
if(values.HasNoValue) | ||
return new Maybe<PagedResult<UserDto>>(); | ||
return new Maybe<IEnumerable<UserDto>>(); | ||
if (query == null) | ||
return values; | ||
|
||
return values.Value.Paginate(query); | ||
return values; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using Coolector.Common.Types; | ||
|
||
namespace Coolector.Core.Filters | ||
{ | ||
public class EmptyFilter<TResult, TQuery> : IFilter<TResult, TQuery> where TQuery : IQuery | ||
{ | ||
public Maybe<IEnumerable<TResult>> Filter(Maybe<IEnumerable<TResult>> values, TQuery query) | ||
{ | ||
return values; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using Autofac; | ||
using Coolector.Common.Types; | ||
|
||
namespace Coolector.Core.Filters | ||
{ | ||
public class FilterResolver : IFilterResolver | ||
{ | ||
private readonly IComponentContext _context; | ||
|
||
public FilterResolver(IComponentContext context) | ||
{ | ||
_context = context; | ||
} | ||
|
||
public IFilter<TResult, TQuery> Resolve<TResult, TQuery>() where TQuery : IQuery | ||
{ | ||
IFilter<TResult, TQuery> filter; | ||
|
||
return _context.TryResolve(out filter) ? filter : new EmptyFilter<TResult, TQuery>(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using Coolector.Common.Types; | ||
|
||
namespace Coolector.Core.Filters | ||
{ | ||
public interface IFilterResolver | ||
{ | ||
IFilter<TResult, TQuery> Resolve<TResult, TQuery>() where TQuery : IQuery; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.