-
Notifications
You must be signed in to change notification settings - Fork 3
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
9280a14
commit 4f5473c
Showing
5 changed files
with
59 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
27 changes: 27 additions & 0 deletions
27
src/Gameboard.Api/Features/Challenge/Requests/SyncChallenge/SyncChallenge.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,27 @@ | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Gameboard.Api.Features.GameEngine; | ||
using Gameboard.Api.Features.Users; | ||
using Gameboard.Api.Structure.MediatR; | ||
using MediatR; | ||
|
||
namespace Gameboard.Api.Features.Challenges; | ||
|
||
public record SyncChallengeCommand(string ChallengeId) : IRequest<GameEngineGameState>; | ||
|
||
internal sealed class SyncChallengeHandler | ||
( | ||
IChallengeSyncService challengeSyncService, | ||
IValidatorService validator | ||
) : IRequestHandler<SyncChallengeCommand, GameEngineGameState> | ||
{ | ||
public async Task<GameEngineGameState> Handle(SyncChallengeCommand request, CancellationToken cancellationToken) | ||
{ | ||
await validator | ||
.Auth(c => c.Require(PermissionKey.Admin_View)) | ||
.AddEntityExistsValidator<Data.Challenge>(request.ChallengeId) | ||
.Validate(cancellationToken); | ||
|
||
return await challengeSyncService.Sync(request.ChallengeId, cancellationToken); | ||
} | ||
} |
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