/// <summary> /// Creates the match secretary. /// </summary> /// <param name="accessToken">The access token.</param> /// <param name="claimsIdentity">The claims identity.</param> /// <param name="viewModel">The view model.</param> /// <param name="cancellationToken">The cancellation token.</param> public async Task CreateMatchSecretary(String accessToken, ClaimsIdentity claimsIdentity, CreateGolfClubUserViewModel viewModel, CancellationToken cancellationToken) { CreateMatchSecretaryRequest createMatchSecretaryRequest = this.ModelFactory.ConvertFrom(viewModel); Guid golfClubId = ApiClient.GetClaimValue <Guid>(claimsIdentity, "GolfClubId"); await this.GolfClubClient.CreateMatchSecretary(accessToken, golfClubId, createMatchSecretaryRequest, cancellationToken); }
/// <summary> /// Converts from. /// </summary> /// <param name="viewModel">The view model.</param> /// <returns></returns> public CreateMatchSecretaryRequest ConvertFrom(CreateGolfClubUserViewModel viewModel) { CreateMatchSecretaryRequest request = new CreateMatchSecretaryRequest { ConfirmPassword = "******", GivenName = viewModel.GivenName, FamilyName = viewModel.FamilyName, MiddleName = viewModel.MiddleName, EmailAddress = viewModel.Email, Password = "******", TelephoneNumber = viewModel.TelephoneNumber }; return(request); }
public void ModelFactory_ConvertFrom_CreateGolfClubUserViewModel_ConvertedSuccessfully() { ModelFactory factory = new ModelFactory(); CreateGolfClubUserViewModel viewModel = ModelFactoryTestData.GetCreateGolfClubUserViewModel(); CreateMatchSecretaryRequest apiRequest = factory.ConvertFrom(viewModel); apiRequest.MiddleName.ShouldBe(viewModel.MiddleName); apiRequest.ConfirmPassword.ShouldBe(ModelFactoryTestData.ConfirmPassword); apiRequest.EmailAddress.ShouldBe(viewModel.Email); apiRequest.FamilyName.ShouldBe(viewModel.FamilyName); apiRequest.GivenName.ShouldBe(viewModel.GivenName); apiRequest.Password.ShouldBe(ModelFactoryTestData.Password); apiRequest.TelephoneNumber.ShouldBe(viewModel.TelephoneNumber); }
public async Task <IActionResult> CreateMatchSecretaryUser(CreateGolfClubUserViewModel model, CancellationToken cancellationToken) { //// Validate the model if (this.ValidateModel(model)) { String accessToken = await this.HttpContext.GetTokenAsync("access_token"); // All good with model, call the client to create the golf club await this.ApiClient.CreateMatchSecretary(accessToken, this.User.Identity as ClaimsIdentity, model, cancellationToken); // GOlf Club Created, redirect to the Club Details screen return(this.RedirectToAction(nameof(this.GetUsersList))); } // If we got this far, something failed, redisplay form return(this.View(model)); }
public async Task <IActionResult> CreateMatchSecretaryUser(CancellationToken cancellationToken) { CreateGolfClubUserViewModel model = new CreateGolfClubUserViewModel(); return(this.View(model)); }
/// <summary> /// Validates the model. /// </summary> /// <param name="model">The model.</param> /// <returns></returns> private Boolean ValidateModel(CreateGolfClubUserViewModel model) { return(this.ModelState.IsValid); }