public async Task <IActionResult> CreateMatchSecretary([FromRoute] Guid golfClubId,
                                                               [FromBody] CreateMatchSecretaryRequest 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());
            }

            CreateMatchSecretaryCommand command = CreateMatchSecretaryCommand.Create(Guid.Parse(golfClubIdClaim.Value), request);

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

            // return the result
            return(this.Created($"{GolfClubController.ControllerRoute}/{golfClubId}/users/{request.EmailAddress}",
                                new CreateMatchSecretaryResponse
            {
                GolfClubId = golfClubId,
                UserName = request.EmailAddress
            }));
        }
Пример #2
0
        public void CreateMatchSecretaryCommand_CanBeCreated_IsCreated()
        {
            CreateMatchSecretaryCommand command = CreateMatchSecretaryCommand.Create(GolfClubTestData.AggregateId, GolfClubTestData.CreateMatchSecretaryRequest);

            command.ShouldNotBeNull();
            command.CommandId.ShouldNotBe(Guid.Empty);
            command.GolfClubId.ShouldBe(GolfClubTestData.AggregateId);
            command.CreateMatchSecretaryRequest.ShouldNotBeNull();
            command.CreateMatchSecretaryRequest.ShouldBe(GolfClubTestData.CreateMatchSecretaryRequest);
        }
        public async Task <IActionResult> CreateMatchSecretary([FromRoute] Guid golfClubId,
                                                               [FromBody] CreateMatchSecretaryRequest request,
                                                               CancellationToken cancellationToken)
        {
            // Get the Golf Club Id claim from the user
            Claim golfClubIdClaim = ClaimsHelper.GetUserClaim(this.User, CustomClaims.GolfClubId);

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

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

            CreateMatchSecretaryCommand command = CreateMatchSecretaryCommand.Create(Guid.Parse(golfClubIdClaim.Value), request);

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

            return(this.NoContent());
        }