public async Task <ActionResult> DeleteCohort(DeleteCommitmentViewModel viewModel) { if (!ModelState.IsValid) { var model = await Orchestrator .GetDeleteCommitmentModel(viewModel.HashedAccountId, viewModel.HashedCommitmentId, OwinWrapper.GetClaimValue(@"sub")); return(View(model)); } if (viewModel.DeleteConfirmed == null || !viewModel.DeleteConfirmed.Value) { return(Redirect(_linkGenerator.CommitmentsV2Link($"{viewModel.HashedAccountId}/unapproved/{viewModel.HashedCommitmentId}"))); } await Orchestrator .DeleteCommitment(viewModel.HashedAccountId, viewModel.HashedCommitmentId, OwinWrapper.GetClaimValue("sub"), OwinWrapper.GetClaimValue(DasClaimTypes.DisplayName), OwinWrapper.GetClaimValue(DasClaimTypes.Email)); var flashmessage = new FlashMessageViewModel { Message = "Records deleted", Severity = FlashMessageSeverityLevel.Okay }; AddFlashMessageToCookie(flashmessage); var anyCohortWithCurrentStatus = await Orchestrator.AnyCohortsForCurrentStatus(viewModel.HashedAccountId, GetRequestStatusFromCookie()); if (!anyCohortWithCurrentStatus) { return(RedirectToAction("YourCohorts", new { viewModel.HashedAccountId })); } return(Redirect(GetReturnToListUrl(viewModel.HashedAccountId))); }