public async Task <ActionResult> CreateAccount() { var enteredData = _employerAccountOrchestrator.GetCookieData(); if (enteredData == null) { // N.B CHANGED THIS FROM SelectEmployer which went nowhere. _employerAccountOrchestrator.DeleteCookieData(); return(RedirectToAction(ControllerConstants.SearchForOrganisationActionName, ControllerConstants.SearchOrganisationControllerName)); } var request = new CreateAccountModel { UserId = GetUserId(), OrganisationType = enteredData.EmployerAccountOrganisationData.OrganisationType, OrganisationReferenceNumber = enteredData.EmployerAccountOrganisationData.OrganisationReferenceNumber, OrganisationName = enteredData.EmployerAccountOrganisationData.OrganisationName, OrganisationAddress = enteredData.EmployerAccountOrganisationData.OrganisationRegisteredAddress, OrganisationDateOfInception = enteredData.EmployerAccountOrganisationData.OrganisationDateOfInception, PayeReference = enteredData.EmployerAccountPayeRefData.PayeReference, AccessToken = enteredData.EmployerAccountPayeRefData.AccessToken, RefreshToken = enteredData.EmployerAccountPayeRefData.RefreshToken, OrganisationStatus = string.IsNullOrWhiteSpace(enteredData.EmployerAccountOrganisationData.OrganisationStatus) ? null : enteredData.EmployerAccountOrganisationData.OrganisationStatus, EmployerRefName = enteredData.EmployerAccountPayeRefData.EmployerRefName, PublicSectorDataSource = enteredData.EmployerAccountOrganisationData.PublicSectorDataSource, Sector = enteredData.EmployerAccountOrganisationData.Sector, HashedAccountId = _accountCookieStorage.Get(_hashedAccountIdCookieName), Aorn = enteredData.EmployerAccountPayeRefData.AORN }; var response = await _employerAccountOrchestrator.CreateOrUpdateAccount(request, HttpContext); if (response.Status == HttpStatusCode.BadRequest) { response.Status = HttpStatusCode.OK; response.FlashMessage = new FlashMessageViewModel { Headline = "There was a problem creating your account" }; return(RedirectToAction(ControllerConstants.SummaryActionName)); } _employerAccountOrchestrator.DeleteCookieData(); var returnUrlCookie = _returnUrlCookieStorageService.Get(ReturnUrlCookieName); _accountCookieStorage.Delete(_hashedAccountIdCookieName); _returnUrlCookieStorageService.Delete(ReturnUrlCookieName); if (returnUrlCookie != null && !returnUrlCookie.Value.IsNullOrWhiteSpace()) { return(Redirect(returnUrlCookie.Value)); } return(RedirectToAction(ControllerConstants.WhenDoYouWantToView, ControllerConstants.EmployerAgreementControllerName, new { hashedAccountId = response.Data.EmployerAgreement.HashedAccountId, agreementId = response.Data.EmployerAgreement.HashedAgreementId })); }
public ActionResult SelectEmployer() { _employerAccountOrchestrator.DeleteCookieData(HttpContext); return(RedirectToAction("AddOrganisation", "EmployerAccountOrganisation")); }