Esempio n. 1
0
        public async Task <DashboardViewModel> GetDashboardViewModelAsync(long ukprn)
        {
            var dashboard = await _vacancyClient.GetDashboardAsync(ukprn);

            if (dashboard == null)
            {
                await _vacancyClient.GenerateDashboard(ukprn);

                dashboard = await _vacancyClient.GetDashboardAsync(ukprn);
            }

            var vm = DashboardMapper.MapFromProviderDashboard(dashboard);

            return(vm);
        }
Esempio n. 2
0
        public async Task <TitleViewModel> GetTitleViewModelForNewVacancyAsync(string employerAccountId, long ukprn)
        {
            await ValidateEmployerAccountIdAsync(ukprn, employerAccountId);

            var dashboard = await _providerVacancyClient.GetDashboardAsync(ukprn);

            var vm = new TitleViewModel
            {
                EmployerAccountId = employerAccountId,
                Ukprn             = ukprn,
                PageInfo          = new PartOnePageInfoViewModel(),
                HasAnyVacancies   = dashboard.Vacancies.Any()
            };

            return(vm);
        }
        public async Task <DashboardViewModel> GetDashboardViewModelAsync(VacancyUser user)
        {
            var dashboardTask   = _vacancyClient.GetDashboardAsync(user.Ukprn.Value, createIfNonExistent: true);
            var userDetailsTask = _client.GetUsersDetailsAsync(user.UserId);

            await Task.WhenAll(dashboardTask, userDetailsTask);

            var dashboard   = dashboardTask.Result;
            var userDetails = userDetailsTask.Result;

            var vacancies = dashboard.Vacancies?.ToList() ?? new List <VacancySummary>();

            var vm = new DashboardViewModel
            {
                Vacancies = vacancies,
                NoOfVacanciesClosingSoonWithNoApplications = vacancies.Count(v =>
                                                                             v.ClosingDate <= _timeProvider.Today.AddDays(ClosingSoonDays) &&
                                                                             v.Status == VacancyStatus.Live &&
                                                                             v.ApplicationMethod == ApplicationMethod.ThroughFindAnApprenticeship &&
                                                                             v.NoOfApplications == 0),
                NoOfVacanciesClosingSoon = vacancies.Count(v =>
                                                           v.ClosingDate <= _timeProvider.Today.AddDays(ClosingSoonDays) &&
                                                           v.Status == VacancyStatus.Live),
                Alerts = _providerAlertsViewModelFactory.Create(dashboard, userDetails)
            };

            return(vm);
        }
Esempio n. 4
0
        public async Task <VacanciesViewModel> GetVacanciesViewModelAsync(
            VacancyUser user, string filter, int page, string searchTerm)
        {
            var getDashboardTask   = _providerVacancyClient.GetDashboardAsync(user.Ukprn.Value, createIfNonExistent: true);
            var getUserDetailsTask = _recruitVacancyClient.GetUsersDetailsAsync(user.UserId);
            var providerTask       = _providerRelationshipsService.GetLegalEntitiesForProviderAsync(user.Ukprn.Value, OperationType.RecruitmentRequiresReview);

            await Task.WhenAll(getDashboardTask, getUserDetailsTask, providerTask);

            var dashboard           = getDashboardTask.Result;
            var userDetails         = getUserDetailsTask.Result;
            var providerPermissions = providerTask.Result;

            var alerts = _providerAlertsViewModelFactory.Create(dashboard, userDetails);

            var vacancies = new List <VacancySummary>(dashboard?.Vacancies ?? Array.Empty <VacancySummary>());

            var filteringOption = SanitizeFilter(filter);

            var filteredVacancies = GetFilteredVacancies(vacancies, filteringOption, searchTerm);

            var filteredVacanciesTotal = filteredVacancies.Count();

            page = SanitizePage(page, filteredVacanciesTotal);

            var skip = (page - 1) * VacanciesPerPage;

            var vacanciesVm = filteredVacancies
                              .Skip(skip)
                              .Take(VacanciesPerPage)
                              .Select(VacancySummaryMapper.ConvertToVacancySummaryViewModel)
                              .ToList();

            var pager = new PagerViewModel(
                filteredVacanciesTotal,
                VacanciesPerPage,
                page,
                "Showing {0} to {1} of {2} vacancies",
                RouteNames.Vacancies_Get,
                new Dictionary <string, string>
            {
                { "filter", filteringOption.ToString() },
                { "searchTerm", searchTerm }
            });

            var vm = new VacanciesViewModel
            {
                Vacancies      = vacanciesVm,
                Pager          = pager,
                Filter         = filteringOption,
                SearchTerm     = searchTerm,
                ResultsHeading = VacancyFilterHeadingHelper.GetFilterHeading(Constants.VacancyTerm, filteredVacanciesTotal, filteringOption, searchTerm, UserType.Provider),
                Alerts         = alerts,
                HasEmployerReviewPermission = providerPermissions.Any()
            };

            return(vm);
        }
        private async Task <IEnumerable <VacancySummary> > GetVacanciesAsync(long ukprn)
        {
            var dashboard = await _providerVacancyClient.GetDashboardAsync(ukprn);

            return(dashboard?.Vacancies?.OrderByDescending(v => v.CreatedDate) ?? Enumerable.Empty <VacancySummary>());
        }
Esempio n. 6
0
        public async Task <AlertsViewModel> CreateAsync(long ukprn, User user)
        {
            var dashboard = await _providerVacancyClient.GetDashboardAsync(ukprn, createIfNonExistent : true);

            return(Create(dashboard, user));
        }