Ejemplo n.º 1
0
        public async Task RegisterPlayer(String golfClubName, TableRow tableRow)
        {
            String clientToken = await this.GetToken(TokenType.Client, "golfhandicap.testdatagenerator", "golfhandicap.testdatagenerator").ConfigureAwait(false);;

            Func <String, String> baseAddressResolver = (address) => { return($"http://127.0.0.1:{this.ManagementAPIPort}"); };
            HttpClient            httpClient          = new HttpClient();
            IPlayerClient         playerClient        = new PlayerClient(baseAddressResolver, httpClient);

            List <GetGolfClubResponse> golfClubList = await playerClient.GetGolfClubList(clientToken, Guid.Empty, CancellationToken.None).ConfigureAwait(false);;

            GetGolfClubResponse golfClub = golfClubList.SingleOrDefault(g => g.Name == golfClubName);

            if (golfClub != null)
            {
                DateTime dateOfBirth = DateTime.Now.AddYears(Int32.Parse(tableRow["Age"]) * -1).AddDays(-1);

                RegisterPlayerRequest registerPlayerRequest = new RegisterPlayerRequest
                {
                    DateOfBirth   = dateOfBirth,
                    EmailAddress  = tableRow["EmailAddress"],
                    Gender        = tableRow["Gender"],
                    ExactHandicap = Decimal.Parse(tableRow["ExactHandicap"]),
                    FamilyName    = tableRow["FamilyName"],
                    GivenName     = tableRow["GivenName"],
                };

                var registerPlayerResponse = await playerClient.RegisterPlayer(registerPlayerRequest, CancellationToken.None).ConfigureAwait(false);

                await playerClient.RequestClubMembership(clientToken, registerPlayerResponse.PlayerId, golfClub.Id, CancellationToken.None).ConfigureAwait(false);
            }
        }