예제 #1
0
        private async Task <IActionResult> StartRoatpApplication(SelectApplicationRouteViewModel model)
        {
            _logger.LogDebug("StartRoatpApplication invoked");

            var applicationDetails = _sessionService.Get <ApplicationDetails>(ApplicationDetailsKey);

            applicationDetails.ApplicationRoute = new ApplicationRoute {
                Id = model.ApplicationRouteId
            };

            var user = await _usersApiClient.GetUserBySignInId(User.GetSignInId());

            applicationDetails.CreatedBy = user.Id;

            var createOrganisationRequest = Mapper.Map <CreateOrganisationRequest>(applicationDetails);

            await _organisationApiClient.Create(createOrganisationRequest, user.Id);

            _sessionService.Set(ApplicationDetailsKey, applicationDetails);

            if (!user.IsApproved)
            {
                await _usersApiClient.ApproveUser(user.Id);
            }

            _logger.LogDebug("StartRoatpApplication completed");

            return(RedirectToAction("Applications", "RoatpApplication", new { applicationType = ApplicationTypes.RegisterTrainingProviders }));
        }