public async Task <OrchestratorResponse <SearchOrganisationResultsViewModel> > SearchOrganisation(string searchTerm, int pageNumber, OrganisationType?organisationType, string hashedAccountId, string userId) { var response = new OrchestratorResponse <SearchOrganisationResultsViewModel>(); try { _cookieService.Delete(CookieName); var result = await Mediator.SendAsync(new GetOrganisationsRequest { SearchTerm = searchTerm, PageNumber = pageNumber, OrganisationType = organisationType }); response.Data = new SearchOrganisationResultsViewModel { Results = CreateResult(result.Organisations), SearchTerm = searchTerm, OrganisationType = organisationType }; if (!string.IsNullOrEmpty(hashedAccountId)) { await SetAlreadySelectedOrganisations(hashedAccountId, userId, response.Data.Results); } } catch (InvalidRequestException ex) { response.Exception = ex; response.FlashMessage = FlashMessageViewModel.CreateErrorFlashMessageViewModel(ex.ErrorMessages); response.Status = HttpStatusCode.BadRequest; } return(response); }
public async Task <ActionResult> Confirm( string hashedAccountId, string name, string code, string address, DateTime?incorporated, string legalEntityStatus, OrganisationType organisationType, short?publicSectorDataSource, string sector) { var request = new CreateNewLegalEntityViewModel { HashedAccountId = hashedAccountId, Name = name, Code = code, Address = address, IncorporatedDate = incorporated, ExternalUserId = OwinWrapper.GetClaimValue(@"sub"), LegalEntityStatus = string.IsNullOrWhiteSpace(legalEntityStatus) ? null : legalEntityStatus, Source = (short)organisationType, PublicSectorDataSource = publicSectorDataSource, Sector = sector }; var response = await _orchestrator.CreateLegalEntity(request); var flashMessage = new FlashMessageViewModel { HiddenFlashMessageInformation = "page-organisations-added", Headline = $"{response.Data.EmployerAgreement.LegalEntityName} has been added", Severity = FlashMessageSeverityLevel.Success }; AddFlashMessageToCookie(flashMessage); return(RedirectToAction("Index", "EmployerAgreement", new { hashedAccountId })); }
public async Task <ActionResult> RenameAccount(RenameEmployerAccountViewModel vm) { var userIdClaim = OwinWrapper.GetClaimValue(ControllerConstants.UserRefClaimKeyName); var response = await _employerAccountOrchestrator.RenameEmployerAccount(vm, userIdClaim); if (response.Status == HttpStatusCode.OK) { var flashmessage = new FlashMessageViewModel { Headline = "Account renamed", Message = "You successfully updated the account name", Severity = FlashMessageSeverityLevel.Success }; AddFlashMessageToCookie(flashmessage); return(RedirectToAction(ControllerConstants.IndexActionName, ControllerConstants.EmployerTeamControllerName)); } var errorResponse = new OrchestratorResponse <RenameEmployerAccountViewModel>(); if (response.Status == HttpStatusCode.BadRequest) { vm.ErrorDictionary = response.FlashMessage.ErrorMessages; } errorResponse.Data = vm; errorResponse.FlashMessage = response.FlashMessage; errorResponse.Status = response.Status; return(View(errorResponse)); }
public async Task <ActionResult> RemovePaye(string hashedAccountId, RemovePayeSchemeViewModel model) { model.UserId = OwinWrapper.GetClaimValue(ControllerConstants.UserRefClaimKeyName); if (model.RemoveScheme == 1) { return(RedirectToAction(ControllerConstants.IndexActionName, ControllerConstants.EmployerAccountPayeControllerName, new { model.HashedAccountId })); } var result = await _employerAccountPayeOrchestrator.RemoveSchemeFromAccount(model); if (result.Status != HttpStatusCode.OK) { return(View(ControllerConstants.RemoveViewName, result)); } model.PayeSchemeName = model.PayeSchemeName ?? string.Empty; var flashMessage = new FlashMessageViewModel { Severity = FlashMessageSeverityLevel.Success, Headline = $"You've removed {model.PayeRef}", SubMessage = model.PayeSchemeName, HiddenFlashMessageInformation = "page-paye-scheme-deleted" }; AddFlashMessageToCookie(flashMessage); return(RedirectToAction(ControllerConstants.IndexActionName, ControllerConstants.EmployerAccountPayeControllerName, new { model.HashedAccountId })); }
public async Task <ActionResult> StatusChangeConfirmation(string hashedAccountId, string hashedApprenticeshipId, [CustomizeValidator(RuleSet = "default,Date,Confirm")] ChangeStatusViewModel model) { if (!await IsUserRoleAuthorized(hashedAccountId, Role.Owner, Role.Transactor)) { return(View("AccessDenied")); } if (!ModelState.IsValid) { var response = await _orchestrator.GetChangeStatusConfirmationViewModel(hashedAccountId, hashedApprenticeshipId, model.ChangeType.Value, model.WhenToMakeChange, model.DateOfChange.DateTime, model.MadeRedundant, OwinWrapper.GetClaimValue(@"sub")); return(View(response)); } if (model.ChangeConfirmed.HasValue && !model.ChangeConfirmed.Value) { return(Redirect(_linkGenerator.CommitmentsV2Link($"{hashedAccountId}/apprentices/{hashedApprenticeshipId}/details"))); } await _orchestrator.UpdateStatus(hashedAccountId, hashedApprenticeshipId, model, OwinWrapper.GetClaimValue(@"sub"), OwinWrapper.GetClaimValue(DasClaimTypes.DisplayName), OwinWrapper.GetClaimValue(DasClaimTypes.Email)); var flashmessage = new FlashMessageViewModel { Message = GetStatusMessage(model.ChangeType), Severity = FlashMessageSeverityLevel.Okay }; AddFlashMessageToCookie(flashmessage); return(Redirect(_linkGenerator.CommitmentsV2Link($"{hashedAccountId}/apprentices/{hashedApprenticeshipId}/details"))); }
public async Task <ActionResult> Confirm() { var userId = GetLoggedInUserId(); var confirmationRequired = await _accountOrchestrator.RequestConfirmAccount(userId); if (!confirmationRequired) { return(RedirectToAction("Index", "Home")); } var flashMessage = new FlashMessageViewModel { Severity = FlashMessageSeverityLevel.Success, Headline = "We've sent you an email", SubMessage = $"To confirm your identity, we've sent a code to {GetLoggedInUserEmail()}" }; var response = new OrchestratorResponse <ActivateUserViewModel>() { FlashMessage = flashMessage, Data = new ActivateUserViewModel() }; return(View("Confirm", response)); }
private static void SetSearchTermValidationModelProperties(OrchestratorResponse model) { model.Status = HttpStatusCode.BadRequest; model.FlashMessage = FlashMessageViewModel.CreateErrorFlashMessageViewModel(new Dictionary <string, string> { { "searchTerm", "Enter organisation name" } }); }
public async Task <ActionResult> RemovePaye(string hashedAccountId, RemovePayeSchemeViewModel model) { model.UserId = OwinWrapper.GetClaimValue("sub"); if (model.RemoveScheme == 1) { return(RedirectToAction("Index", "EmployerAccountPaye", new { model.HashedAccountId })); } var result = await _employerAccountPayeOrchestrator.RemoveSchemeFromAccount(model); if (result.Status != HttpStatusCode.OK) { return(View("Remove", result)); } var flashMessage = new FlashMessageViewModel { Severity = FlashMessageSeverityLevel.Success, Headline = $"You've removed {model.PayeRef}", HiddenFlashMessageInformation = "page-paye-scheme-deleted" }; AddFlashMessageToCookie(flashMessage); return(RedirectToAction("Index", "EmployerAccountPaye", new { model.HashedAccountId })); }
public async Task <ActionResult> Accept(long invitation, UserInvitationsViewModel model) { if (string.IsNullOrEmpty(OwinWrapper.GetClaimValue("sub"))) { return(RedirectToAction("Index", "Home")); } var invitationItem = model.Invitations.SingleOrDefault(c => c.Id == invitation); if (invitationItem == null) { return(RedirectToAction("Index", "Home")); } await _invitationOrchestrator.AcceptInvitation(invitationItem.Id, OwinWrapper.GetClaimValue("sub")); var flashMessage = new FlashMessageViewModel { Headline = "Invitation accepted", Message = $"You can now access the {invitationItem.AccountName} account", Severity = FlashMessageSeverityLevel.Success }; AddFlashMessageToCookie(flashMessage); return(RedirectToAction("Index", "Home")); }
public async Task <ActionResult> Invite(InviteTeamMemberViewModel model) { var response = await _employerTeamOrchestrator.InviteTeamMember(model, OwinWrapper.GetClaimValue(@"sub")); if (response.Status == HttpStatusCode.OK) { var flashMessage = new FlashMessageViewModel { HiddenFlashMessageInformation = "page-invite-team-member-sent", Severity = FlashMessageSeverityLevel.Success, Headline = "Invitation sent", Message = $"You've sent an invitation to <strong>{model.Email}</strong>" }; AddFlashMessageToCookie(flashMessage); return(RedirectToAction("ViewTeam")); } model.ErrorDictionary = response.FlashMessage.ErrorMessages; var errorResponse = new OrchestratorResponse <InviteTeamMemberViewModel> { Data = model, FlashMessage = response.FlashMessage, }; return(View(errorResponse)); }
public async Task <ActionResult> View(string agreementId, string hashedAccountId, FlashMessageViewModel flashMessage) { var agreement = await GetSignedAgreementViewModel(new GetEmployerAgreementRequest { AgreementId = agreementId, HashedAccountId = hashedAccountId, ExternalUserId = OwinWrapper.GetClaimValue(ControllerConstants.UserRefClaimKeyName) }); return(View(agreement)); }
public async Task <ActionResult> View(string agreementId, string hashedAccountId, FlashMessageViewModel flashMessage) { var agreement = await _orchestrator.GetById(agreementId, hashedAccountId, OwinWrapper.GetClaimValue(ControllerConstants.UserRefClaimKeyName)); return(View(agreement)); }
private void SetSuccessMessage(string message) { var flashmessage = new FlashMessageViewModel { Message = message, Severity = FlashMessageSeverityLevel.Success }; AddFlashMessageToCookie(flashmessage); }
protected void SetInfoMessage(string messageText, FlashMessageSeverityLevel level) { var message = new FlashMessageViewModel { Message = messageText, Severity = level }; _flashMessage.Delete(FlashMessageCookieName); _flashMessage.Create(message, FlashMessageCookieName); }
public virtual async Task <OrchestratorResponse <bool> > RemoveLegalAgreement(ConfirmLegalAgreementToRemoveViewModel model, string userId) { var response = new OrchestratorResponse <bool>(); try { if (model.RemoveOrganisation == null) { response.Status = HttpStatusCode.BadRequest; response.FlashMessage = FlashMessageViewModel.CreateErrorFlashMessageViewModel(new Dictionary <string, string> { { "RemoveOrganisation", "Confirm you wish to remove the organisation" } }); return(response); } if (model.RemoveOrganisation == 1) { response.Status = HttpStatusCode.Continue; return(response); } await _mediator.SendAsync(new RemoveLegalEntityCommand { HashedAccountId = model.HashedAccountId, UserId = userId, HashedLegalAgreementId = model.HashedAgreementId }); response.FlashMessage = new FlashMessageViewModel { Headline = $"You have removed {model.Name}.", Severity = FlashMessageSeverityLevel.Success }; response.Data = true; } catch (InvalidRequestException ex) { response.Status = HttpStatusCode.BadRequest; response.FlashMessage = FlashMessageViewModel.CreateErrorFlashMessageViewModel(ex.ErrorMessages); response.Exception = ex; } catch (UnauthorizedAccessException ex) { response.Status = HttpStatusCode.Unauthorized; response.Exception = ex; } return(response); }
public ActionResult HandlePasswordChanged(bool userCancelled = false) { if (!userCancelled) { var flashMessage = new FlashMessageViewModel { Severity = FlashMessageSeverityLevel.Success, Headline = "You've changed your password" }; AddFlashMessageToCookie(flashMessage); } return(RedirectToAction(ControllerConstants.IndexActionName)); }
public async Task <ActionResult> CreateAccount() { var enteredData = _employerAccountOrchestrator.GetCookieData(HttpContext); if (enteredData == null) { return(RedirectToAction("SelectEmployer", "EmployerAccount")); } var request = new CreateAccountViewModel { UserId = GetUserId(), OrganisationType = enteredData.OrganisationType, OrganisationReferenceNumber = enteredData.OrganisationReferenceNumber, OrganisationName = enteredData.OrganisationName, OrganisationAddress = enteredData.OrganisationRegisteredAddress, OrganisationDateOfInception = enteredData.OrganisationDateOfInception, PayeReference = enteredData.PayeReference, AccessToken = enteredData.AccessToken, RefreshToken = enteredData.RefreshToken, OrganisationStatus = string.IsNullOrWhiteSpace(enteredData.OrganisationStatus) ? null : enteredData.OrganisationStatus, EmployerRefName = enteredData.EmployerRefName, PublicSectorDataSource = enteredData.PublicSectorDataSource, Sector = enteredData.Sector }; var response = await _employerAccountOrchestrator.CreateAccount(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("summary")); } var flashmessage = new FlashMessageViewModel { Headline = "Account created", HiddenFlashMessageInformation = enteredData.OrganisationType.ToString(), Severity = FlashMessageSeverityLevel.Success }; AddFlashMessageToCookie(flashmessage); return(RedirectToAction("Index", "EmployerTeam", new { response.Data.EmployerAgreement.HashedAccountId })); }
public async Task <ActionResult> Confirm( string hashedAccountId, string name, string code, string address, DateTime?incorporated, string legalEntityStatus, OrganisationType organisationType, byte?publicSectorDataSource, string sector, bool newSearch) { var request = new CreateNewLegalEntityViewModel { HashedAccountId = hashedAccountId, Name = name, Code = code, Address = address, IncorporatedDate = incorporated, ExternalUserId = OwinWrapper.GetClaimValue(ControllerConstants.UserRefClaimKeyName), LegalEntityStatus = string.IsNullOrWhiteSpace(legalEntityStatus) ? null : legalEntityStatus, Source = organisationType, PublicSectorDataSource = publicSectorDataSource, Sector = sector }; var response = await _orchestrator.CreateLegalEntity(request); var flashMessage = new FlashMessageViewModel { HiddenFlashMessageInformation = "page-organisations-added", Headline = $"{response.Data.EmployerAgreement.LegalEntityName} has been added", Severity = FlashMessageSeverityLevel.Success }; AddFlashMessageToCookie(flashMessage); if (newSearch) { return(RedirectToAction(ControllerConstants.OrganisationAddedNextStepsSearchActionName, new { hashedAccountId, organisationName = name, hashedAgreementId = response.Data.EmployerAgreement.HashedAgreementId })); } return(RedirectToAction(ControllerConstants.OrganisationAddedNextStepsActionName, new { hashedAccountId, organisationName = name, hashedAgreementId = response.Data.EmployerAgreement.HashedAgreementId })); }
public async Task <ActionResult> NotificationSettings(NotificationSettingsViewModel vm) { var userIdClaim = OwinWrapper.GetClaimValue(ControllerConstants.UserRefClaimKeyName); await _userSettingsOrchestrator.UpdateNotificationSettings(userIdClaim, vm.NotificationSettings); var flashMessage = new FlashMessageViewModel { Severity = FlashMessageSeverityLevel.Success, Message = "Settings updated." }; AddFlashMessageToCookie(flashMessage); return(RedirectToAction(ControllerConstants.NotificationSettingsActionName)); }
public async Task <ActionResult> Sign(string agreementId, string hashedAccountId) { var userInfo = OwinWrapper.GetClaimValue(ControllerConstants.UserRefClaimKeyName); var agreement = await _orchestrator.GetById(agreementId, hashedAccountId, userInfo); var response = await _orchestrator.SignAgreement(agreementId, hashedAccountId, userInfo, DateTime.UtcNow, agreement.Data.EmployerAgreement.LegalEntityName); if (response.Status == HttpStatusCode.OK) { FlashMessageViewModel flashMessage = new FlashMessageViewModel { Headline = "Agreement signed", Severity = FlashMessageSeverityLevel.Success }; ActionResult result; if (response.Data.HasFurtherPendingAgreements) { flashMessage.Message = "You've successfully signed an organisation agreement. There are outstanding agreements to be signed. Review the list below to sign all remaining agreements."; result = RedirectToAction(ControllerConstants.IndexActionName, ControllerConstants.EmployerAgreementControllerName, new { hashedAccountId, agreementSigned = true }); } else { flashMessage.Headline = "All agreements signed"; flashMessage.Message = "You've successfully signed all of your organisation agreements."; result = RedirectToAction(ControllerConstants.NextStepsActionName); } AddFlashMessageToCookie(flashMessage); return(result); } agreement.Exception = response.Exception; agreement.Status = response.Status; return(View(ControllerConstants.SignAgreementViewName, agreement.Data)); }
public async Task <ActionResult> SubmitChanges(string hashedAccountId, string hashedApprenticeshipId, UpdateApprenticeshipViewModel apprenticeship) { if (!await IsUserRoleAuthorized(hashedAccountId, Role.Owner, Role.Transactor)) { return(View("AccessDenied")); } var orginalApp = await _orchestrator.GetApprenticeship(hashedAccountId, hashedApprenticeshipId, OwinWrapper.GetClaimValue(@"sub")); apprenticeship.OriginalApprenticeship = orginalApp.Data; if (!ModelState.IsValid) { var viewmodel = await _orchestrator.GetOrchestratorResponseUpdateApprenticeshipViewModelFromCookie(hashedAccountId, hashedApprenticeshipId); viewmodel.Data.AddErrorsFromModelState(ModelState); SetErrorMessage(viewmodel, viewmodel.Data.ErrorDictionary); return(View("ConfirmChanges", viewmodel)); } if (apprenticeship.ChangesConfirmed != null && !apprenticeship.ChangesConfirmed.Value) { return(RedirectToAction("Details", new { hashedAccountId, hashedApprenticeshipId })); } await _orchestrator.CreateApprenticeshipUpdate(apprenticeship, hashedAccountId, OwinWrapper.GetClaimValue(@"sub"), OwinWrapper.GetClaimValue(DasClaimTypes.DisplayName), OwinWrapper.GetClaimValue(DasClaimTypes.Email)); var message = NeedReapproval(apprenticeship) ? "Suggested changes sent to training provider for approval, where needed." : "Apprentice updated"; var flashmessage = new FlashMessageViewModel { Message = message, Severity = FlashMessageSeverityLevel.Okay }; AddFlashMessageToCookie(flashmessage); return(RedirectToAction("Details", new { hashedAccountId, hashedApprenticeshipId })); }
public async Task <ActionResult> ConfirmPayeScheme(string hashedAccountId, AddNewPayeSchemeViewModel model) { var result = await _employerAccountPayeOrchestrator.AddPayeSchemeToAccount(model, OwinWrapper.GetClaimValue("sub")); if (result.Status != HttpStatusCode.OK) { return(View(result)); } var flashMessage = new FlashMessageViewModel { Severity = FlashMessageSeverityLevel.Success, Headline = $"You've added {model.PayeScheme}", HiddenFlashMessageInformation = "page-paye-scheme-added" }; AddFlashMessageToCookie(flashMessage); return(RedirectToAction("Index", "EmployerAccountPaye", new { model.HashedAccountId })); }
public virtual async Task <OrchestratorResponse <UnlockUserViewModel> > ResendUnlockCode(UnlockUserViewModel model) { try { await _mediator.SendAsync(new ResendUnlockCodeCommand { Email = model.Email, ReturnUrl = model.ReturnUrl }); model.UnlockCodeSent = true; var flashMessage = new FlashMessageViewModel { Severity = FlashMessageSeverityLevel.Success, Headline = "Unlock your account", SubMessage = "We've resent an email with a code to unlock your account" }; return(new OrchestratorResponse <UnlockUserViewModel> { Data = model, FlashMessage = flashMessage }); } catch (InvalidRequestException ex) { _logger.Info(ex, ex.Message); model.ErrorDictionary = ex.ErrorMessages; var flashMessage = new FlashMessageViewModel { ErrorMessages = ex.ErrorMessages, Headline = "Errors to fix", Message = "Check the following details:", Severity = FlashMessageSeverityLevel.Error }; return(new OrchestratorResponse <UnlockUserViewModel> { Data = model, FlashMessage = flashMessage });; } }
public async Task <ActionResult> ConfirmPayeScheme(string hashedAccountId, AddNewPayeSchemeViewModel model) { var result = await _employerAccountPayeOrchestrator.AddPayeSchemeToAccount(model, OwinWrapper.GetClaimValue(ControllerConstants.UserRefClaimKeyName)); if (result.Status != HttpStatusCode.OK) { return(View(result)); } var payeSchemeName = string.IsNullOrEmpty(model.PayeName) ? "this PAYE scheme" : model.PayeName; var flashMessage = new FlashMessageViewModel { Severity = FlashMessageSeverityLevel.Success, Headline = $"{model.PayeScheme} has been added", HiddenFlashMessageInformation = "page-paye-scheme-added" }; AddFlashMessageToCookie(flashMessage); return(RedirectToAction(ControllerConstants.NextStepsActionName, ControllerConstants.EmployerAccountPayeControllerName, new { model.HashedAccountId })); }
public async Task <ActionResult> HandleEmailChanged(bool userCancelled = false) { if (!userCancelled) { var flashMessage = new FlashMessageViewModel { Severity = FlashMessageSeverityLevel.Success, Headline = "You've changed your email" }; AddFlashMessageToCookie(flashMessage); await OwinWrapper.UpdateClaims(); var userRef = OwinWrapper.GetClaimValue(ControllerConstants.UserRefClaimKeyName); var email = OwinWrapper.GetClaimValue(ControllerConstants.EmailClaimKeyName); var firstName = OwinWrapper.GetClaimValue(DasClaimTypes.GivenName); var lastName = OwinWrapper.GetClaimValue(DasClaimTypes.FamilyName); await _homeOrchestrator.SaveUpdatedIdentityAttributes(userRef, email, firstName, lastName); } return(RedirectToAction(ControllerConstants.IndexActionName)); }
public async Task <ActionResult> FinishedEditing(FinishEditingViewModel viewModel) { if (!ModelState.IsValid) { var response = await _employerCommitmentsOrchestrator.GetFinishEditingViewModel(viewModel.HashedAccountId, OwinWrapper.GetClaimValue(@"sub"), viewModel.HashedCommitmentId); response.Data = viewModel; return(View(response)); } if (viewModel.SaveStatus.IsSend()) { return(RedirectToAction("SubmitExistingCommitment", new { viewModel.HashedAccountId, viewModel.HashedCommitmentId, viewModel.SaveStatus })); } if (viewModel.SaveStatus.IsFinalApproval()) { var userDisplayName = OwinWrapper.GetClaimValue(DasClaimTypes.DisplayName); var userEmail = OwinWrapper.GetClaimValue(DasClaimTypes.Email); var userId = OwinWrapper.GetClaimValue(@"sub"); await _employerCommitmentsOrchestrator.ApproveCommitment(viewModel.HashedAccountId, userId, userDisplayName, userEmail, viewModel.HashedCommitmentId, viewModel.SaveStatus); return(RedirectToAction("Approved", new { viewModel.HashedAccountId, viewModel.HashedCommitmentId })); } var flashmessage = new FlashMessageViewModel { Headline = "Details saved but not sent", Severity = FlashMessageSeverityLevel.Info }; AddFlashMessageToCookie(flashmessage); return(RedirectToAction("YourCohorts", new { hashedAccountId = viewModel.HashedAccountId })); }
public async Task <ActionResult> DeleteApprenticeshipConfirmation(DeleteApprenticeshipConfirmationViewModel viewModel) { if (!ModelState.IsValid) { var errorResponse = await _employerCommitmentsOrchestrator.GetDeleteApprenticeshipViewModel(viewModel.HashedAccountId, OwinWrapper.GetClaimValue(@"sub"), viewModel.HashedCommitmentId, viewModel.HashedApprenticeshipId); return(View(errorResponse)); } if (viewModel.DeleteConfirmed.HasValue && viewModel.DeleteConfirmed.Value) { await _employerCommitmentsOrchestrator.DeleteApprenticeship(viewModel, OwinWrapper.GetClaimValue(@"sub"), OwinWrapper.GetClaimValue(DasClaimTypes.DisplayName), OwinWrapper.GetClaimValue(DasClaimTypes.Email)); var flashMessage = new FlashMessageViewModel { Severity = FlashMessageSeverityLevel.Okay, Message = string.Format($"Apprentice record for {viewModel.ApprenticeshipName} deleted") }; AddFlashMessageToCookie(flashMessage); return(RedirectToAction("Details", new { viewModel.HashedAccountId, viewModel.HashedCommitmentId })); } return(RedirectToAction("EditApprenticeship", new { viewModel.HashedAccountId, viewModel.HashedCommitmentId, viewModel.HashedApprenticeshipId })); }
public async Task <ActionResult> Sign(string agreementId, string hashedAccountId) { var response = await _orchestrator.SignAgreement(agreementId, hashedAccountId, OwinWrapper.GetClaimValue(@"sub"), DateTime.UtcNow); if (response.Status == HttpStatusCode.OK) { var flashMessage = new FlashMessageViewModel { Headline = "Agreement signed", Severity = FlashMessageSeverityLevel.Success }; AddFlashMessageToCookie(flashMessage); return(RedirectToAction("Index", new { hashedAccountId })); } var agreement = await _orchestrator.GetById(agreementId, hashedAccountId, OwinWrapper.GetClaimValue(@"sub")); agreement.Exception = response.Exception; agreement.Status = response.Status; return(View("SignAgreement", agreement)); }
public virtual async Task <OrchestratorResponse <ConfirmOrganisationToRemoveViewModel> > RemoveLegalAgreement(ConfirmOrganisationToRemoveViewModel model, string userId) { var response = new OrchestratorResponse <ConfirmOrganisationToRemoveViewModel>(); try { await _mediator.SendAsync(new RemoveLegalEntityCommand { HashedAccountId = model.HashedAccountId, UserId = userId, HashedAccountLegalEntityId = model.HashedAccountLegalEntitytId }); response.FlashMessage = new FlashMessageViewModel { Headline = $"You have removed {model.Name}.", Severity = FlashMessageSeverityLevel.Success }; response.Status = HttpStatusCode.OK; response.Data = model; } catch (InvalidRequestException ex) { response.Status = HttpStatusCode.BadRequest; response.FlashMessage = FlashMessageViewModel.CreateErrorFlashMessageViewModel(ex.ErrorMessages); response.Exception = ex; } catch (UnauthorizedAccessException ex) { response.Status = HttpStatusCode.Unauthorized; response.Exception = ex; } return(response); }
public async Task <ActionResult> DeleteCohort(DeleteCommitmentViewModel viewModel) { if (!ModelState.IsValid) { var model = await _employerCommitmentsOrchestrator .GetDeleteCommitmentModel(viewModel.HashedAccountId, viewModel.HashedCommitmentId, OwinWrapper.GetClaimValue(@"sub")); return(View(model)); } if (viewModel.DeleteConfirmed == null || !viewModel.DeleteConfirmed.Value) { return(RedirectToAction("Details", new { viewModel.HashedAccountId, viewModel.HashedCommitmentId })); } await _employerCommitmentsOrchestrator .DeleteCommitment(viewModel.HashedAccountId, viewModel.HashedCommitmentId, OwinWrapper.GetClaimValue("sub"), OwinWrapper.GetClaimValue(DasClaimTypes.DisplayName), OwinWrapper.GetClaimValue(DasClaimTypes.Email)); var flashmessage = new FlashMessageViewModel { Message = "Cohort deleted", Severity = FlashMessageSeverityLevel.Okay }; AddFlashMessageToCookie(flashmessage); var anyCohortWithCurrentStatus = await _employerCommitmentsOrchestrator.AnyCohortsForCurrentStatus(viewModel.HashedAccountId, GetSessionRequestStatus()); if (!anyCohortWithCurrentStatus) { return(RedirectToAction("YourCohorts", new { viewModel.HashedAccountId })); } return(Redirect(GetReturnToListUrl(viewModel.HashedAccountId))); }