-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4eb6b97
commit 34f5e8d
Showing
14 changed files
with
107 additions
and
28 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
32 changes: 32 additions & 0 deletions
32
src/Subjects/Core.Application/Business/Queries/GetBusinessesAllQuery.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,32 @@ | ||
using Goodtocode.Common.Extensions; | ||
using Goodtocode.Subjects.Domain; | ||
using MediatR; | ||
|
||
namespace Goodtocode.Subjects.Application; | ||
|
||
public class GetBusinessesAllQuery : IRequest<PagedResult<BusinessEntity>> | ||
{ | ||
public string BusinessName { get; set; } = string.Empty; | ||
public int Page { get; set; } = 1; | ||
public int Results { get; set; } = 20; | ||
} | ||
|
||
public class GetBusinessesAllQueryHandler : IRequestHandler<GetBusinessesAllQuery, PagedResult<BusinessEntity>> | ||
{ | ||
private readonly IBusinessRepo _userBusinessesRepo; | ||
|
||
public GetBusinessesAllQueryHandler(IBusinessRepo userBusinessesRepo) | ||
{ | ||
_userBusinessesRepo = userBusinessesRepo; | ||
} | ||
|
||
public async Task<PagedResult<BusinessEntity>> Handle(GetBusinessesAllQuery request, | ||
CancellationToken cancellationToken) | ||
{ | ||
var businesses = | ||
await _userBusinessesRepo.GetBusinessesAllAsync(request.BusinessName, request.Page, request.Results, | ||
cancellationToken); | ||
|
||
return businesses.GetValueOrDefault(); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
src/Subjects/Core.Application/Business/Queries/GetBusinessesAllQueryValidator.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,13 @@ | ||
using FluentValidation; | ||
|
||
namespace Goodtocode.Subjects.Application; | ||
|
||
public class GetBusinessesAllQueryValidator : AbstractValidator<GetBusinessesAllQuery> | ||
{ | ||
public GetBusinessesAllQueryValidator() | ||
{ | ||
RuleFor(x => x.BusinessName).NotEmpty(); | ||
RuleFor(x => x.Results).GreaterThan(0); | ||
RuleFor(x => x.Page).GreaterThan(0); | ||
} | ||
} |
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
9 changes: 9 additions & 0 deletions
9
src/Subjects/Presentation.Api.WebApi/Goodtocode.Subjects.WebApi.xml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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