public async Task <IActionResult> AddTournamentDivision([FromRoute] Guid golfClubId,
                                                                [FromBody] AddTournamentDivisionToGolfClubRequest request,
                                                                CancellationToken cancellationToken)
        {
            // Get the Golf Club Id claim from the user
            Claim golfClubIdClaim = ClaimsHelper.GetUserClaim(this.User, CustomClaims.GolfClubId, golfClubId.ToString());

            Boolean validationResult = ClaimsHelper.ValidateRouteParameter(golfClubId, golfClubIdClaim);

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

            // Create the command
            AddTournamentDivisionToGolfClubCommand command = AddTournamentDivisionToGolfClubCommand.Create(Guid.Parse(golfClubIdClaim.Value), request);

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

            // return the result
            return(this.Created($"{GolfClubController.ControllerRoute}/{golfClubId}/tournamentdivisions/{request.Division}",
                                new AddTournamentDivisionToGolfClubResponse
            {
                GolfClubId = golfClubId,
                TournamentDivision = request.Division
            }));
        }
Ejemplo n.º 2
0
        public void AddTournamentDivisionToGolfClubCommand_CanBeCreated_IsCreated()
        {
            AddTournamentDivisionToGolfClubCommand command =
                AddTournamentDivisionToGolfClubCommand.Create(GolfClubTestData.AggregateId, GolfClubTestData.AddTournamentDivisionToGolfClubRequest);

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