Esempio n. 1
0
        /// <summary>
        /// Registers the golf club administrator.
        /// </summary>
        /// <param name="viewModel">The view model.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        public async Task RegisterGolfClubAdministrator(RegisterClubAdministratorViewModel viewModel,
                                                        CancellationToken cancellationToken)
        {
            // Translate view model to request
            RegisterClubAdministratorRequest registerRegisterClubAdministratorRequest = this.ModelFactory.ConvertFrom(viewModel);

            await this.GolfClubClient.RegisterGolfClubAdministrator(registerRegisterClubAdministratorRequest, cancellationToken);
        }
        public async Task RegistrationController_POST_Register_LoginScreenShown()
        {
            RegisterClubAdministratorViewModel viewModel = new RegisterClubAdministratorViewModel();

            Mock <IClient>         client     = new Mock <IClient>();
            RegistrationController controller = new RegistrationController(client.Object);

            IActionResult result = await controller.Register(viewModel, CancellationToken.None);

            RedirectToActionResult redirect = result.ShouldBeOfType <RedirectToActionResult>();

            redirect.ActionName.ShouldBe("Registered");
        }
        public void ModelFactory_ConvertFrom_RegisterClubAdministratorViewModel_ConvertedSuccessfully()
        {
            ModelFactory factory = new ModelFactory();

            RegisterClubAdministratorViewModel viewModel = ModelFactoryTestData.GetRegisterClubAdministratorViewModel();

            RegisterClubAdministratorRequest request = factory.ConvertFrom(viewModel);

            request.ConfirmPassword.ShouldBe(viewModel.ConfirmPassword);
            request.EmailAddress.ShouldBe(viewModel.Email);
            request.Password.ShouldBe(viewModel.Password);
            request.TelephoneNumber.ShouldBe(viewModel.TelephoneNumber);
        }
Esempio n. 4
0
        /// <summary>
        /// Converts from.
        /// </summary>
        /// <param name="viewModel">The view model.</param>
        /// <returns></returns>
        public RegisterClubAdministratorRequest ConvertFrom(RegisterClubAdministratorViewModel viewModel)
        {
            RegisterClubAdministratorRequest registerRegisterClubAdministratorRequest = new RegisterClubAdministratorRequest
            {
                ConfirmPassword = viewModel.ConfirmPassword,
                EmailAddress    = viewModel.Email,
                Password        = viewModel.Password,
                TelephoneNumber = viewModel.TelephoneNumber,
                FamilyName      = viewModel.LastName,
                GivenName       = viewModel.FirstName,
                MiddleName      = string.Empty
            };

            return(registerRegisterClubAdministratorRequest);
        }
        public async Task RegistrationController_POST_Register_ErrorsDisplayed()
        {
            RegisterClubAdministratorViewModel viewModel = new RegisterClubAdministratorViewModel();

            Mock <IClient>         client     = new Mock <IClient>();
            RegistrationController controller = new RegistrationController(client.Object);

            controller.ModelState.AddModelError("FirstName", "Required");

            IActionResult result = await controller.Register(viewModel, CancellationToken.None);

            ViewResult viewResult = result.ShouldBeOfType <ViewResult>();

            viewResult.ViewData.ModelState.IsValid.ShouldBeFalse();
            viewResult.ViewData.ModelState.ErrorCount.ShouldBe(1);
        }
Esempio n. 6
0
        public async Task <IActionResult> Register(RegisterClubAdministratorViewModel model,
                                                   CancellationToken cancellationToken,
                                                   String returnUrl = null)
        {
            // Validate the model
            if (this.ValidateModel(model))
            {
                // All good with model, call the security client to register the user
                await this.ApiClient.RegisterGolfClubAdministrator(model, cancellationToken);

                // Club Administrator registered, redirect to a Login Screen
                return(this.RedirectToAction(nameof(this.Registered)));
            }

            // If we got this far, something failed, redisplay form
            return(this.View(model));
        }
Esempio n. 7
0
 /// <summary>
 /// Validates the model.
 /// </summary>
 /// <param name="model">The model.</param>
 /// <returns></returns>
 private Boolean ValidateModel(RegisterClubAdministratorViewModel model)
 {
     return(this.ModelState.IsValid);
 }