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))); }