public async Task <IActionResult> GetGolfClub([FromRoute] Guid golfClubId,
                                                      [FromQuery] Boolean includeMembers,
                                                      [FromQuery] Boolean includeMeasuredCourses,
                                                      [FromQuery] Boolean includeUsers,
                                                      [FromQuery] Boolean includeTournaments,
                                                      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());
            }

            GetGolfClubResponsev1 getGolfClubResponsev1 = await this.Manager.GetGolfClub(Guid.Parse(golfClubIdClaim.Value), cancellationToken);

            List <GetGolfClubMembershipDetailsResponse> membersList = null;

            if (includeMembers)
            {
                membersList = await this.Manager.GetGolfClubMembersList(Guid.Parse(golfClubIdClaim.Value), cancellationToken);
            }

            GetMeasuredCourseListResponse measuredCourseList = null;

            if (includeMeasuredCourses)
            {
                measuredCourseList = await this.Manager.GetMeasuredCourseList(Guid.Parse(golfClubIdClaim.Value), cancellationToken);
            }

            GetGolfClubUserListResponse users = null;

            if (includeUsers)
            {
                users = await this.Manager.GetGolfClubUsers(Guid.Parse(golfClubIdClaim.Value), cancellationToken);
            }

            GetTournamentListResponse tournamentList = null;

            if (includeTournaments)
            {
                tournamentList = await this.Manager.GetTournamentList(Guid.Parse(golfClubIdClaim.Value), cancellationToken);
            }

            GetGolfClubResponsev2 getGolfClubResponsev2 = this.ConvertGetGolfClubResponse(getGolfClubResponsev1, membersList, measuredCourseList, users, tournamentList);

            return(this.Ok(getGolfClubResponsev2));
        }
        private GetGolfClubResponsev2 ConvertGetGolfClubResponse(GetGolfClubResponsev1 getGolfClubResponsev1,
                                                                 List <GetGolfClubMembershipDetailsResponse> membersList = null,
                                                                 GetMeasuredCourseListResponse measuredCourseList        = null,
                                                                 GetGolfClubUserListResponse users        = null,
                                                                 GetTournamentListResponse tournamentList = null)
        {
            GetGolfClubResponsev2 response = new GetGolfClubResponsev2
            {
                TelephoneNumber = getGolfClubResponsev1.TelephoneNumber,
                EmailAddress    = getGolfClubResponsev1.EmailAddress,
                Name            = getGolfClubResponsev1.Name,
                AddressLine1    = getGolfClubResponsev1.AddressLine1,
                AddressLine2    = getGolfClubResponsev1.AddressLine2,
                Id         = getGolfClubResponsev1.Id,
                PostalCode = getGolfClubResponsev1.PostalCode,
                Region     = getGolfClubResponsev1.Region,
                Town       = getGolfClubResponsev1.Town,
                Website    = getGolfClubResponsev1.Website,
            };

            if (membersList != null)
            {
                response.GolfClubMembershipDetailsResponseList = new List <GolfClubMembershipDetailsResponse>();

                foreach (GetGolfClubMembershipDetailsResponse getGolfClubMembershipDetailsResponse in membersList)
                {
                    response.GolfClubMembershipDetailsResponseList.Add(new GolfClubMembershipDetailsResponse
                    {
                        MembershipStatus  = (MembershipStatusv2)getGolfClubMembershipDetailsResponse.MembershipStatus,
                        PlayerId          = getGolfClubMembershipDetailsResponse.PlayerId,
                        Name              = getGolfClubMembershipDetailsResponse.Name,
                        MembershipNumber  = getGolfClubMembershipDetailsResponse.MembershipNumber,
                        PlayerDateOfBirth = getGolfClubMembershipDetailsResponse.PlayerDateOfBirth,
                        PlayerFullName    = getGolfClubMembershipDetailsResponse.PlayerFullName,
                        PlayerGender      = getGolfClubMembershipDetailsResponse.PlayerGender
                    });
                }
            }

            if (measuredCourseList != null)
            {
                response.MeasuredCourses = new List <MeasuredCourseListResponse>();

                foreach (DataTransferObjects.Responses.MeasuredCourseListResponse measuredCourseListResponse in measuredCourseList.MeasuredCourses)
                {
                    response.MeasuredCourses.Add(new MeasuredCourseListResponse
                    {
                        MeasuredCourseId     = measuredCourseListResponse.MeasuredCourseId,
                        Name                 = measuredCourseListResponse.Name,
                        TeeColour            = measuredCourseListResponse.TeeColour,
                        StandardScratchScore = measuredCourseListResponse.StandardScratchScore
                    });
                }
            }

            if (users != null)
            {
                response.Users = new List <GolfClubUserResponse>();

                foreach (DataTransferObjects.Responses.GolfClubUserResponse user in users.Users)
                {
                    response.Users.Add(new GolfClubUserResponse
                    {
                        UserId      = user.UserId,
                        FamilyName  = user.FamilyName,
                        GivenName   = user.GivenName,
                        MiddleName  = user.MiddleName,
                        Email       = user.Email,
                        PhoneNumber = user.PhoneNumber,
                        UserName    = user.UserName,
                        UserType    = user.UserType
                    });
                }
            }

            if (tournamentList != null)
            {
                response.Tournaments = new List <TournamentResponse>();

                foreach (DataTransferObjects.Responses.GetTournamentResponse tournamentListTournament in tournamentList.Tournaments)
                {
                    response.Tournaments.Add(new TournamentResponse
                    {
                        MeasuredCourseId           = tournamentListTournament.MeasuredCourseId,
                        TournamentFormat           = (TournamentFormat)tournamentListTournament.TournamentFormat,
                        TournamentDate             = tournamentListTournament.TournamentDate,
                        MeasuredCourseName         = tournamentListTournament.MeasuredCourseName,
                        TournamentId               = tournamentListTournament.TournamentId,
                        MeasuredCourseTeeColour    = tournamentListTournament.MeasuredCourseTeeColour,
                        TournamentName             = tournamentListTournament.TournamentName,
                        HasBeenCancelled           = tournamentListTournament.HasBeenCancelled,
                        HasBeenCompleted           = tournamentListTournament.HasBeenCompleted,
                        HasResultBeenProduced      = tournamentListTournament.HasResultBeenProduced,
                        MeasuredCourseSSS          = tournamentListTournament.MeasuredCourseSSS,
                        PlayerCategory             = (PlayerCategory)tournamentListTournament.PlayerCategory,
                        PlayersScoresRecordedCount = tournamentListTournament.PlayersScoresRecordedCount,
                        PlayersSignedUpCount       = tournamentListTournament.PlayersSignedUpCount
                    });
                }
            }

            return(response);
        }