public async Task <IActionResult> RequestClubMembership([FromRoute] Guid golfClubId,
                                                                [FromRoute] Guid playerId,
                                                                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
            RequestClubMembershipCommand command = RequestClubMembershipCommand.Create(Guid.Parse(playerIdClaim.Value), golfClubId);

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

            // return the result
            return(this.Created($"api/players/{playerId}",
                                new RequestClubMembershipResponse
            {
                GolfClubId = golfClubId,
                PlayerId = playerId,
                MembershipId = Guid.Empty
            }));
        }
Beispiel #2
0
        public void RequestClubMembershipCommand_CanBeCreated_IsCreated()
        {
            RequestClubMembershipCommand command = RequestClubMembershipCommand.Create(GolfClubTestData.PlayerId, GolfClubTestData.AggregateId);

            command.ShouldNotBeNull();
            command.CommandId.ShouldNotBe(Guid.Empty);
            command.PlayerId.ShouldBe(GolfClubTestData.PlayerId);
            command.GolfClubId.ShouldBe(GolfClubTestData.AggregateId);
        }