Example #1
0
        public async Task <OrchestratorResponse <DataLockStatusViewModel> > GetDataLockStatusForRestartRequest(string hashedAccountId, string hashedApprenticeshipId, string userId)
        {
            var accountId        = HashingService.DecodeValue(hashedAccountId);
            var apprenticeshipId = HashingService.DecodeValue(hashedApprenticeshipId);

            return(await CheckUserAuthorization(
                       async() =>
            {
                var dataLockSummary = await Mediator.SendAsync(
                    new GetDataLockSummaryQueryRequest {
                    AccountId = accountId, ApprenticeshipId = apprenticeshipId
                });

                //var dataLock = dataLocks.DataLockStatus
                //    .First(m => m.TriageStatus == TriageStatus.Restart);
                var dataLock = dataLockSummary.DataLockSummary
                               .DataLockWithCourseMismatch.FirstOrDefault(m => m.TriageStatus == TriageStatus.Restart);

                if (dataLock == null)
                {
                    throw new InvalidStateException($"No data locks exist that can be restarted for apprenticeship: {apprenticeshipId}");
                }

                var apprenticeship = await Mediator.SendAsync(
                    new GetApprenticeshipQueryRequest {
                    AccountId = accountId, ApprenticeshipId = apprenticeshipId
                });

                var programms = await GetTrainingProgrammes(true);
                var currentProgram = programms.Single(m => m.CourseCode == apprenticeship.Apprenticeship.TrainingCode);
                var newProgram = programms.Single(m => m.CourseCode == dataLock.IlrTrainingCourseCode);

                return new OrchestratorResponse <DataLockStatusViewModel>
                {
                    Data = new DataLockStatusViewModel
                    {
                        HashedAccountId = hashedAccountId,
                        HashedApprenticeshipId = hashedApprenticeshipId,
                        CurrentProgram = currentProgram,
                        IlrProgram = newProgram,
                        PeriodStartData = dataLock.IlrEffectiveFromDate,
                        PeriodEndData = dataLock.IlrEffectiveToDate,
                        ProviderName = apprenticeship.Apprenticeship.ProviderName,
                        LearnerName = apprenticeship.Apprenticeship.ApprenticeshipName,
                        DateOfBirth = apprenticeship.Apprenticeship.DateOfBirth,
                        ApprenticeDetailsV2Link = _linkGenerator.CommitmentsV2Link($"{hashedAccountId}/apprentices/{hashedApprenticeshipId}/details")
                    }
                };
            }, hashedAccountId, userId));
        }
Example #2
0
        public string CommitmentsV2Link(string routeName, params string[] args)
        {
            var route = _routes.CommitmentsV2[routeName];

            if (args != null && args.Length > 0)
            {
                route = string.Format(route, args);
            }

            return(_generator.CommitmentsV2Link(route));
        }
 private string GetChangeOfProviderLink(string hashedAccountId, string hashedApprenticeshipId)
 {
     if (_featureToggleService.Get <ChangeOfProvider>().FeatureEnabled)
     {
         return(_linkGenerator.CommitmentsV2Link($"{hashedAccountId}/apprentices/{hashedApprenticeshipId}/change-provider"));
     }
     else
     {
         return(String.Empty);
     }
 }
        public async Task <OrchestratorResponse <EditApprenticeshipStopDateViewModel> > GetEditApprenticeshipStopDateViewModel(string hashedAccountId, string hashedApprenticeshipId, string externalUserId)
        {
            var accountId        = HashingService.DecodeValue(hashedAccountId);
            var apprenticeshipId = HashingService.DecodeValue(hashedApprenticeshipId);

            Logger.Info(
                $"Getting On-programme apprenticeships Provider: {accountId}, ApprenticeshipId: {apprenticeshipId}");

            return(await CheckUserAuthorization(async() =>
            {
                var data = await Mediator.SendAsync(
                    new GetApprenticeshipQueryRequest {
                    AccountId = accountId, ApprenticeshipId = apprenticeshipId
                });

                var stopDateEditModel =
                    _apprenticeshipMapper.MapToEditApprenticeshipStopDateViewModel(data.Apprenticeship);
                stopDateEditModel.ApprenticeDetailsV2Link = _linkGenerator.CommitmentsV2Link($"{hashedAccountId}/apprentices/{hashedApprenticeshipId}/details");

                return new OrchestratorResponse <EditApprenticeshipStopDateViewModel> {
                    Data = stopDateEditModel
                };
            }, hashedAccountId, externalUserId));
        }
 public ActionResult ListAll(string hashedAccountId)
 {
     return(Redirect(_linkGenerator.CommitmentsV2Link($"{hashedAccountId}/apprentices")));
 }
 public ActionResult Index(string hashedAccountId)
 {
     return(Redirect(_linkGenerator.CommitmentsV2Link($"{hashedAccountId}")));
 }