public async Task <IActionResult> ChooseStandardForWithdrawal(ChooseStandardForWithdrawalViewModel viewModel) { if (!viewModel.SelectedStandardForWithdrawal.HasValue) { ModelState.AddModelError(nameof(viewModel.SelectedStandardForWithdrawal), "Select the standard you want to withdraw from assessing"); } if (ModelState.IsValid) { var contact = await GetUserContact(); var organisation = await _orgApiClient.GetOrganisationByUserId(contact.Id); var createApplicationRequest = await _applicationService.BuildStandardWithdrawalRequest( contact, organisation, viewModel.SelectedStandardForWithdrawal.Value, _config.ReferenceFormat); var id = await _applicationApiClient.CreateApplication(createApplicationRequest); var standards = await _applicationApiClient.GetStandards(); var selectedStandard = standards.FirstOrDefault(s => s.StandardId == viewModel.SelectedStandardForWithdrawal); await _applicationApiClient.UpdateStandardData(id, selectedStandard.Id, selectedStandard.ReferenceNumber, selectedStandard.Title); return(RedirectToAction( nameof(ApplicationController.Sequence), nameof(ApplicationController).RemoveController(), new { Id = id, sequenceNo = ApplyConst.STANDARD_WITHDRAWAL_SEQUENCE_NO })); } return(RedirectToAction(nameof(ChooseStandardForWithdrawal), nameof(ApplyForWithdrawalController).RemoveController())); }
private async Task <Guid> CreateWithdrawalApplication(ContactResponse contact, OrganisationResponse organisation, int larsCode, string iFateReferenceNumber, string standardTitle, string standardOrVersion, IEnumerable <string> versions) { var createApplicationRequest = await _applicationService.BuildStandardWithdrawalRequest( contact, organisation, larsCode, _config.ReferenceFormat, standardOrVersion); var id = await _applicationApiClient.CreateApplication(createApplicationRequest); var standardApplicationType = versions != null && versions.Any() ? StandardApplicationTypes.VersionWithdrawal : StandardApplicationTypes.StandardWithdrawal; await _applicationApiClient.UpdateStandardData(id, larsCode, iFateReferenceNumber, standardTitle, versions?.ToList(), standardApplicationType); return(id); }