Exemplo n.º 1
0
        public async Task <PeriodEndViewModel> GetPathState(int?collectionYear, int?period, CancellationToken cancellationToken)
        {
            var currentYearPeriod = await _periodService.ReturnPeriod(CollectionType, cancellationToken);

            currentYearPeriod.Year = currentYearPeriod.Year ?? 0;

            collectionYear = collectionYear ?? currentYearPeriod.Year.Value;
            period         = period ?? currentYearPeriod.Period;

            var pathItemStates = await GetPathItemStatesAsync(collectionYear, period, CollectionType, cancellationToken);

            var state = _stateService.GetMainState(pathItemStates);
            var lastItemJobsFinished = _stateService.AllJobsHaveCompleted(state);

            var files = await GetSubmissionsPerPeriodAsync(collectionYear.Value, period.Value, cancellationToken);

            var model = new PeriodEndViewModel
            {
                Period                = period.Value,
                Year                  = collectionYear.Value,
                Paths                 = state.Paths,
                PeriodEndStarted      = state.PeriodEndStarted,
                PeriodEndFinished     = state.PeriodEndFinished,
                ClosePeriodEndEnabled = lastItemJobsFinished,
                Files                 = files
            };

            var isCurrentPeriodSelected = currentYearPeriod.Year == model.Year && currentYearPeriod.Period == model.Period;

            model.IsCurrentPeriod  = isCurrentPeriodSelected;
            model.CollectionClosed = isCurrentPeriodSelected && currentYearPeriod.PeriodClosed;

            return(model);
        }
        private async Task <PeriodEndViewModel> ShowPath(int collectionYear, int period)
        {
            var pathItemStates = await _periodEndService.GetPathItemStatesAsync(collectionYear, period);

            var state = _stateService.GetMainState(pathItemStates);
            var lastItemJobsFinished = _stateService.AllJobsHaveCompleted(state);

            var pathModel = new PeriodEndViewModel
            {
                Period                   = period,
                Year                     = collectionYear,
                Paths                    = state.Paths,
                CollectionClosed         = state.CollectionClosed,
                PeriodEndStarted         = state.PeriodEndStarted,
                McaReportsReady          = state.McaReportsReady,
                McaReportsPublished      = state.McaReportsPublished,
                ProviderReportsReady     = state.ProviderReportsReady,
                ProviderReportsPublished = state.ProviderReportsPublished,
                PeriodEndFinished        = state.PeriodEndFinished,
                ReferenceDataJobsPaused  = state.ReferenceDataJobsPaused,
                ClosePeriodEndEnabled    = lastItemJobsFinished
            };

            return(pathModel);
        }
        public async Task <IActionResult> Index(CancellationToken cancellationToken)
        {
            var ilrPeriodEndInfo  = _periodService.ReturnPeriod(CollectionTypes.ILR, cancellationToken);
            var ncsPeriodEndInfo  = _periodService.ReturnPeriod(CollectionTypes.NCS, cancellationToken);
            var allfPeriodEndInfo = _periodService.ReturnPeriod(CollectionTypes.ALLF, cancellationToken);

            await Task.WhenAll(ilrPeriodEndInfo, ncsPeriodEndInfo, allfPeriodEndInfo);

            var model = new PeriodEndViewModel
            {
                ILRPeriodEndInfo  = ilrPeriodEndInfo.Result,
                NCSPeriodEndInfo  = ncsPeriodEndInfo.Result,
                ALLFPeriodEndInfo = allfPeriodEndInfo.Result
            };

            return(View(model));
        }