Пример #1
0
        public async Task <HttpResponseMessage> Search(HttpRequestMessage request, [FromBody] VacancySearchInputDTO value)
        {
            try
            {
                var vacancies = await vacancyElasticService.Search(value.Skip, value.Amount, value.SearchModel, value.SortModel)
                                .ConfigureAwait(false);

                var result = Mapper.Map <IEnumerable <VacancyElasticModel>, IEnumerable <VacancyPreviewDTO> >(vacancies);

                return(request.CreateResponse(HttpStatusCode.OK, result));
            }
            catch (Exception ex)
            {
                logger.Error(ex, JsonConvert.SerializeObject(value));

                return(request.CreateResponse(HttpStatusCode.InternalServerError));
            }
        }
Пример #2
0
        public async Task <HttpResponseMessage> GetExcelByVacancies(HttpRequestMessage request, VacancySearchInputDTO value)
        {
            try
            {
                var response = Request.CreateResponse();

                response.Headers.AcceptRanges.Add("bytes");

                response.StatusCode = HttpStatusCode.OK;

                var excel = await fileService.GetExcelByVacancies(value.Skip, value.Amount,
                                                                  value.SearchModel, value.SortModel);

                response.Content = excel;

                return(response);
            }
            catch (Exception ex)
            {
                logger.Error(ex, JsonConvert.SerializeObject(value));

                return(request.CreateResponse(HttpStatusCode.InternalServerError));
            }
        }