Пример #1
0
        public async Task <IActionResult> TypeOfWithdrawal(TypeOfWithdrawalViewModel viewModel)
        {
            if (string.IsNullOrEmpty(viewModel.TypeOfWithdrawal))
            {
                ModelState.AddModelError(nameof(viewModel.TypeOfWithdrawal), "Select if you’re withdrawing from a standard or the register");
            }

            if (ModelState.IsValid)
            {
                if (viewModel.TypeOfWithdrawal == ApplicationTypes.OrganisationWithdrawal)
                {
                    var contact = await GetUserContact();

                    var organisation = await _orgApiClient.GetOrganisationByUserId(contact.Id);

                    var createApplicationRequest = await _applicationService.BuildOrganisationWithdrawalRequest(
                        contact,
                        organisation,
                        _config.ReferenceFormat);

                    var id = await _applicationApiClient.CreateApplication(createApplicationRequest);

                    return(RedirectToAction(
                               nameof(ApplicationController.Sequence),
                               nameof(ApplicationController).RemoveController(),
                               new { Id = id, sequenceNo = ApplyConst.ORGANISATION_WITHDRAWAL_SEQUENCE_NO }));
                }
                else if (viewModel.TypeOfWithdrawal == ApplicationTypes.StandardWithdrawal)
                {
                    return(RedirectToAction(nameof(ChooseStandardForWithdrawal), nameof(ApplyForWithdrawalController).RemoveController()));
                }
            }

            return(RedirectToAction(nameof(TypeOfWithdrawal), nameof(ApplyForWithdrawalController).RemoveController()));
        }
        private async Task <Guid> CreateOrganisationWithdrawalApplication(ContactResponse contact, OrganisationResponse organisation)
        {
            var createApplicationRequest = await _applicationService.BuildOrganisationWithdrawalRequest(
                contact,
                organisation,
                _config.ReferenceFormat);

            return(await _applicationApiClient.CreateApplication(createApplicationRequest));
        }