public void Setup()
        {
            _logger        = new Mock <ILogger <DashboardController> >();
            _apiClient     = new Mock <IApplicationApiClient>();
            _configuration = new Mock <IWebConfiguration>();
            _statusCounts  = new ApplicationReviewStatusCounts
            {
                OrganisationApplicationsNew         = 1,
                OrganisationApplicationsInProgress  = 2,
                OrganisationApplicationsHasFeedback = 3,
                OrganisationApplicationsApproved    = 4,
                StandardApplicationsNew             = 5,
                StandardApplicationsInProgress      = 6,
                StandardApplicationsHasFeedback     = 7,
                StandardApplicationsApproved        = 8
            };
            _dashboardUrl = "http://dashboard";

            _apiClient.Setup(x => x.GetApplicationReviewStatusCounts()).ReturnsAsync(_statusCounts);

            _configuration.Setup(c => c.RoatpOversightBaseUrl).Returns(_dashboardUrl);
            _configuration.Setup(c => c.RoatpAssessorBaseUrl).Returns(_dashboardUrl);
            _configuration.Setup(c => c.RoatpGatewayBaseUrl).Returns(_dashboardUrl);
            _configuration.Setup(c => c.RoatpFinanceBaseUrl).Returns(_dashboardUrl);

            _controller = new DashboardController(_logger.Object, _apiClient.Object, _configuration.Object);
        }
        public async Task <IActionResult> Index()
        {
            ApplicationReviewStatusCounts applicationReviewStatusCounts;

            try
            {
                applicationReviewStatusCounts = await _applicationApiClient.GetApplicationReviewStatusCounts();
            }
            catch (Exception ex) when(ex is HttpRequestException || ex is UnsupportedMediaTypeException)
            {
                _logger.LogError(ex, "Unable to GetApplicationReviewStatusCounts from EPAO Service");
                // Absorb the exception at this point but make it obvious that something has gone wrong. We don't want to kill the Staff Dashboard so soon!
                applicationReviewStatusCounts = new ApplicationReviewStatusCounts
                {
                    OrganisationApplicationsNew         = short.MinValue,
                    OrganisationApplicationsInProgress  = short.MinValue,
                    OrganisationApplicationsHasFeedback = short.MinValue,
                    OrganisationApplicationsApproved    = short.MinValue,
                    StandardApplicationsNew             = short.MinValue,
                    StandardApplicationsInProgress      = short.MinValue,
                    StandardApplicationsHasFeedback     = short.MinValue,
                    StandardApplicationsApproved        = short.MinValue,
                    WithdrawalApplicationsNew           = short.MinValue,
                    WithdrawalApplicationsInProgress    = short.MinValue,
                    WithdrawalApplicationsHasFeedback   = short.MinValue,
                    WithdrawalApplicationsApproved      = short.MinValue,
                };
            }

            var viewModel = new DashboardViewModel
            {
                OrganisationApplicationsNew         = applicationReviewStatusCounts.OrganisationApplicationsNew,
                OrganisationApplicationsInProgress  = applicationReviewStatusCounts.OrganisationApplicationsInProgress,
                OrganisationApplicationsHasFeedback = applicationReviewStatusCounts.OrganisationApplicationsHasFeedback,
                OrganisationApplicationsApproved    = applicationReviewStatusCounts.OrganisationApplicationsApproved,
                StandardApplicationsNew             = applicationReviewStatusCounts.StandardApplicationsNew,
                StandardApplicationsInProgress      = applicationReviewStatusCounts.StandardApplicationsInProgress,
                StandardApplicationsHasFeedback     = applicationReviewStatusCounts.StandardApplicationsHasFeedback,
                StandardApplicationsApproved        = applicationReviewStatusCounts.StandardApplicationsApproved,
                WithdrawalApplicationsNew           = applicationReviewStatusCounts.WithdrawalApplicationsNew,
                WithdrawalApplicationsInProgress    = applicationReviewStatusCounts.WithdrawalApplicationsInProgress,
                WithdrawalApplicationsHasFeedback   = applicationReviewStatusCounts.WithdrawalApplicationsHasFeedback,
                WithdrawalApplicationsApproved      = applicationReviewStatusCounts.WithdrawalApplicationsApproved,
                RoatpOversightBaseUrl = _configuration.RoatpOversightBaseUrl,
                RoatpAssessorBaseUrl  = _configuration.RoatpAssessorBaseUrl,
                RoatpGatewayBaseUrl   = _configuration.RoatpGatewayBaseUrl,
                RoatpFinanceBaseUrl   = _configuration.RoatpFinanceBaseUrl
            };

            return(View(viewModel));
        }
예제 #3
0
        public async Task <ApplicationReviewStatusCounts> GetApplicationReviewStatusCounts()
        {
            var @params = new DynamicParameters();

            @params.Add("includedNewApplicationSequenceStatus", GetApplicationSequenceStatus(ApplicationReviewStatus.New));
            @params.Add("includedInProgressApplicationSequenceStatus", GetApplicationSequenceStatus(ApplicationReviewStatus.InProgress));
            @params.Add("includedHasFeedbackApplicationSequenceStatus", GetApplicationSequenceStatus(ApplicationReviewStatus.HasFeedback));
            @params.Add("includedApprovedApplicationSequenceStatus", GetApplicationSequenceStatus(ApplicationReviewStatus.Approved));
            @params.Add("excludedApplicationStatus", string.Join("|", new List <string> {
                ApplicationStatus.Declined
            }));
            @params.Add("excludedReviewStatus", string.Join("|", new List <string> {
                ApplicationReviewStatus.Deleted
            }));
            @params.Add("includedNewReviewStatus", ApplicationReviewStatus.New);
            @params.Add("includedInProgressReviewStatus", ApplicationReviewStatus.InProgress);
            @params.Add("includedHasFeedbackReviewStatus", ApplicationReviewStatus.HasFeedback);
            @params.Add("includedApprovedReviewStatus", ApplicationReviewStatus.Approved);

            var reviewStatusCountResults = (await _unitOfWork.Connection.QueryMultipleAsync(
                                                "Apply_Get_ReviewStatusCounts",
                                                param: @params,
                                                transaction: _unitOfWork.Transaction,
                                                commandType: CommandType.StoredProcedure));

            var organisationReviewStatusCounts = reviewStatusCountResults.Read <ReviewStatusCount>().ToList();
            var standardReviewStatusCounts     = reviewStatusCountResults.Read <ReviewStatusCount>().ToList();
            var withdrawalReviewStatusCounts   = reviewStatusCountResults.Read <ReviewStatusCount>().ToList();

            var applicationReviewStatusCounts = new ApplicationReviewStatusCounts
            {
                OrganisationApplicationsNew         = organisationReviewStatusCounts?.FirstOrDefault(p => p.ReviewStatus == ApplicationReviewStatus.New)?.Total ?? 0,
                OrganisationApplicationsInProgress  = organisationReviewStatusCounts?.FirstOrDefault(p => p.ReviewStatus == ApplicationReviewStatus.InProgress)?.Total ?? 0,
                OrganisationApplicationsHasFeedback = organisationReviewStatusCounts?.FirstOrDefault(p => p.ReviewStatus == ApplicationReviewStatus.HasFeedback)?.Total ?? 0,
                OrganisationApplicationsApproved    = organisationReviewStatusCounts?.FirstOrDefault(p => p.ReviewStatus == ApplicationReviewStatus.Approved)?.Total ?? 0,
                StandardApplicationsNew             = standardReviewStatusCounts?.FirstOrDefault(p => p.ReviewStatus == ApplicationReviewStatus.New)?.Total ?? 0,
                StandardApplicationsInProgress      = standardReviewStatusCounts?.FirstOrDefault(p => p.ReviewStatus == ApplicationReviewStatus.InProgress)?.Total ?? 0,
                StandardApplicationsHasFeedback     = standardReviewStatusCounts?.FirstOrDefault(p => p.ReviewStatus == ApplicationReviewStatus.HasFeedback)?.Total ?? 0,
                StandardApplicationsApproved        = standardReviewStatusCounts?.FirstOrDefault(p => p.ReviewStatus == ApplicationReviewStatus.Approved)?.Total ?? 0,
                WithdrawalApplicationsNew           = withdrawalReviewStatusCounts?.FirstOrDefault(p => p.ReviewStatus == ApplicationReviewStatus.New)?.Total ?? 0,
                WithdrawalApplicationsInProgress    = withdrawalReviewStatusCounts?.FirstOrDefault(p => p.ReviewStatus == ApplicationReviewStatus.InProgress)?.Total ?? 0,
                WithdrawalApplicationsHasFeedback   = withdrawalReviewStatusCounts?.FirstOrDefault(p => p.ReviewStatus == ApplicationReviewStatus.HasFeedback)?.Total ?? 0,
                WithdrawalApplicationsApproved      = withdrawalReviewStatusCounts?.FirstOrDefault(p => p.ReviewStatus == ApplicationReviewStatus.Approved)?.Total ?? 0,
            };

            return(applicationReviewStatusCounts);
        }