コード例 #1
0
        public async Task <ActionResult> Activate(ActivationViewModel model)
        {
            return(await Task.Run <ActionResult>(() =>
            {
                var response = _registerMediator.Activate(UserContext.CandidateId, model);

                switch (response.Code)
                {
                case RegisterMediatorCodes.Activate.SuccessfullyActivated:
                    SetUserMessage(response.Message.Text);
                    var candidate = _candidateServiceProvider.GetCandidate(model.EmailAddress);
                    UserData.SetUserContext(candidate.RegistrationDetails.EmailAddress,
                                            candidate.RegistrationDetails.FirstName + " " + candidate.RegistrationDetails.LastName,
                                            candidate.RegistrationDetails.AcceptedTermsAndConditionsVersion);
                    return RedirectToRoute(RouteNames.MonitoringInformation);

                case RegisterMediatorCodes.Activate.InvalidActivationCode:
                case RegisterMediatorCodes.Activate.FailedValidation:
                    response.ValidationResult.AddToModelState(ModelState, string.Empty);
                    break;

                case RegisterMediatorCodes.Activate.ErrorActivating:
                    SetUserMessage(response.Message.Text, response.Message.Level);
                    break;

                default:
                    throw new InvalidMediatorCodeException(response.Code);
                }

                return View("Activation", model);
            }));
        }
コード例 #2
0
        public async Task <ActionResult> Activate(ActivationViewModel model)
        {
            return(await Task.Run(() =>
            {
                var response = _registerMediator.Activate(UserContext.CandidateId, model);

                switch (response.Code)
                {
                case RegisterMediatorCodes.Activate.SuccessfullyActivated:
                    SetUserMessage(response.Message.Text);
                    return SetAuthenticationCookieAndRedirectToAction(model.EmailAddress);

                case RegisterMediatorCodes.Activate.InvalidActivationCode:
                case RegisterMediatorCodes.Activate.FailedValidation:
                    response.ValidationResult.AddToModelState(ModelState, string.Empty);
                    break;

                case RegisterMediatorCodes.Activate.ErrorActivating:
                    SetUserMessage(response.Message.Text, response.Message.Level);
                    break;

                default:
                    throw new InvalidMediatorCodeException(response.Code);
                }

                return View("Activation", model);
            }));
        }