示例#1
0
        public async Task <GetEmployerSummaryResponse> Handle(GetEmployerSummaryQuery request, CancellationToken cancellationToken)
        {
            var validationErrors = ValidateRequest(request);

            if (validationErrors.Any())
            {
                return(new GetEmployerSummaryResponse {
                    ResultCode = ResponseCode.InvalidRequest, ValidationErrors = validationErrors.Cast <object>().ToList()
                });
            }

            var dashboard = await _queryStoreReader.GetEmployerDashboardAsync(request.EmployerAccountId);

            if (dashboard == null)
            {
                return(new GetEmployerSummaryResponse {
                    ResultCode = ResponseCode.NotFound
                });
            }

            return(new GetEmployerSummaryResponse
            {
                ResultCode = ResponseCode.Success,
                Data = EmployerAccountSummaryMapper.MapFromEmployerDashboard(dashboard, request.EmployerAccountId)
            });
        }
        public async Task <EmployerDashboard> GetDashboardAsync(string employerAccountId, bool createIfNonExistent = false)
        {
            var dashboard = await _reader.GetEmployerDashboardAsync(employerAccountId);

            if (dashboard == null && createIfNonExistent)
            {
                await GenerateDashboard(employerAccountId);

                dashboard = await GetDashboardAsync(employerAccountId);
            }

            return(dashboard);
        }
示例#3
0
        public async Task <GetVacanciesResponse> Handle(GetVacanciesQuery request, CancellationToken cancellationToken)
        {
            var validationErrors = ValidateRequest(request);

            if (validationErrors.Any())
            {
                return(new GetVacanciesResponse {
                    ResultCode = ResponseCode.InvalidRequest, ValidationErrors = validationErrors.Cast <object>().ToList()
                });
            }

            IList <VacancySummaryProjection> vacancies;
            var isRequestingProviderOwnedVacancies = request.Ukprn.HasValue;

            if (isRequestingProviderOwnedVacancies)
            {
                var dashboard = await _queryStoreReader.GetProviderDashboardAsync(request.Ukprn.Value);

                vacancies = dashboard?
                            .Vacancies
                            .Where(vs => vs.EmployerAccountId.Equals(request.EmployerAccountId))
                            .ToList();
            }
            else
            {
                var dashboard = await _queryStoreReader.GetEmployerDashboardAsync(request.EmployerAccountId);

                vacancies = dashboard?.Vacancies.ToList();
            }

            if (vacancies == null || vacancies.Any() == false)
            {
                return(new GetVacanciesResponse {
                    ResultCode = ResponseCode.NotFound
                });
            }

            if (request.LegalEntityId.HasValue)
            {
                vacancies = vacancies.Where(vs => vs.LegalEntityId == request.LegalEntityId.Value).ToList();

                if (vacancies.Any() == false)
                {
                    return(new GetVacanciesResponse {
                        ResultCode = ResponseCode.NotFound
                    });
                }
            }

            var totalVacancies = vacancies.Count;
            var pageNo         = PagingHelper.GetRequestedPageNo(request.PageNo, request.PageSize, totalVacancies);
            var totalPages     = PagingHelper.GetTotalNoOfPages(request.PageSize, totalVacancies);

            var responseVacancies = GetVacanciesForPage(vacancies, pageNo, request.PageSize, isRequestingProviderOwnedVacancies);

            return(new GetVacanciesResponse
            {
                ResultCode = ResponseCode.Success,
                Data = new VacanciesSummary(responseVacancies, request.PageSize, pageNo, totalVacancies, totalPages)
            });
        }
示例#4
0
 public Task <EmployerDashboard> GetDashboardAsync(string employerAccountId)
 {
     return(_reader.GetEmployerDashboardAsync(employerAccountId));
 }