-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from Tim-Maes/feature/updates
Update template config
- Loading branch information
Showing
7 changed files
with
44 additions
and
4 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
28 changes: 28 additions & 0 deletions
28
src/GraphR.Application/Books/Handlers/Query/GetBooksForAuthorQueryHandler.cs
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,28 @@ | ||
using FluentValidation; | ||
using GraphR.Application.Books.Types.Input; | ||
using GraphR.Application.Books.Types.Mappings; | ||
using GraphR.Application.Books.Types.Output; | ||
using GraphR.Domain.Interfaces.Repositories; | ||
using GrapR.Core.Handlers; | ||
|
||
namespace GraphR.Application.Books.Handlers.Query; | ||
internal sealed class GetBooksForAuthorQueryHandler | ||
: Handler<GetBooksForAuthorParameters, BookDto[]>, IGetBooksForAuthorQueryHandler | ||
{ | ||
private readonly IBookRepository _bookRepository; | ||
|
||
public GetBooksForAuthorQueryHandler(IBookRepository bookRepository) | ||
{ | ||
_bookRepository = bookRepository; | ||
} | ||
|
||
protected override void DefineRules() | ||
{ | ||
RuleFor(x => x.AuthorId).GreaterThan(0); | ||
} | ||
|
||
protected override async Task<BookDto[]> HandleValidatedRequest(GetBooksForAuthorParameters request) | ||
=> (await _bookRepository.GetByAuthorId(request.AuthorId)).ToOutput(); | ||
} | ||
|
||
public interface IGetBooksForAuthorQueryHandler : IHandler<GetBooksForAuthorParameters, BookDto[]> { } |
6 changes: 6 additions & 0 deletions
6
src/GraphR.Application/Books/Types/Input/GetBooksForAuthorParameters.cs
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,6 @@ | ||
namespace GraphR.Application.Books.Types.Input; | ||
|
||
public sealed class GetBooksForAuthorParameters | ||
{ | ||
public int AuthorId { get; set; } | ||
} |
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