Пример #1
0
        public void RecordMemberTournamentScoreCommand_CanBeCreated_IsCreated()
        {
            RecordPlayerTournamentScoreCommand command =
                RecordPlayerTournamentScoreCommand.Create(TournamentTestData.PlayerId, TournamentTestData.AggregateId, TournamentTestData.RecordMemberTournamentScoreRequest);

            command.ShouldNotBeNull();
            command.CommandId.ShouldNotBe(Guid.Empty);
            command.TournamentId.ShouldBe(TournamentTestData.AggregateId);
            command.PlayerId.ShouldBe(TournamentTestData.PlayerId);
            command.RecordPlayerTournamentScoreRequest.ShouldNotBeNull();
            command.RecordPlayerTournamentScoreRequest.ShouldBe(TournamentTestData.RecordMemberTournamentScoreRequest);
        }
Пример #2
0
        public async Task <IActionResult> RecordPlayerScore([FromRoute] Guid playerId,
                                                            [FromRoute] Guid tournamentId,
                                                            [FromBody] RecordPlayerTournamentScoreRequest request,
                                                            CancellationToken cancellationToken)
        {
            // Get the Player Id claim from the user
            Claim playerIdClaim = ClaimsHelper.GetUserClaim(this.User, CustomClaims.PlayerId, playerId.ToString());

            Boolean validationResult = ClaimsHelper.ValidateRouteParameter(playerId, playerIdClaim);

            if (validationResult == false)
            {
                return(this.Forbid());
            }

            // Create the command
            RecordPlayerTournamentScoreCommand command = RecordPlayerTournamentScoreCommand.Create(Guid.Parse(playerIdClaim.Value), tournamentId, request);

            // Route the command
            await this.CommandRouter.Route(command, cancellationToken);

            // return the result
            return(this.Ok());
        }
 public static RecordPlayerTournamentScoreCommand GetRecordPlayerTournamentScoreCommand()
 {
     return(RecordPlayerTournamentScoreCommand.Create(TournamentTestData.PlayerId, TournamentTestData.AggregateId, TournamentTestData.RecordMemberTournamentScoreRequest));
 }