public async Task <GetJobsByStatusesResponse> GetJobsByStatuses(GetJobsByStatusesRequest getJobsByStatusesRequest)
        {
            using (HttpResponseMessage response = await _httpClientWrapper.GetAsync(HttpClientConfigName.RequestService, "/api/GetJobsByStatuses", getJobsByStatusesRequest, CancellationToken.None))
            {
                string jsonResponse = await response.Content.ReadAsStringAsync();

                var sendEmailResponse = JsonConvert.DeserializeObject <ResponseWrapper <GetJobsByStatusesResponse, RequestServiceErrorCode> >(jsonResponse);
                if (sendEmailResponse.HasContent && sendEmailResponse.IsSuccessful)
                {
                    return(sendEmailResponse.Content);
                }
            }
            return(null);
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Function, "get", Route = null)]
            [RequestBodyType(typeof(GetJobsByStatusesRequest), "jobs by statuses request")] GetJobsByStatusesRequest req,
            CancellationToken cancellationToken)
        {
            try
            {
                _logger.LogInformation("GetJobsByStatuses started");
                GetJobsByStatusesResponse response = await _mediator.Send(req, cancellationToken);

                return(new OkObjectResult(ResponseWrapper <GetJobsByStatusesResponse, RequestServiceErrorCode> .CreateSuccessfulResponse(response)));
            }
            catch (Exception exc)
            {
                _logger.LogErrorAndNotifyNewRelic("Exception occured in GetJobsByStatuses", exc);
                return(new ObjectResult(ResponseWrapper <GetJobsByStatusesResponse, RequestServiceErrorCode> .CreateUnsuccessfulResponse(RequestServiceErrorCode.InternalServerError, "Internal Error"))
                {
                    StatusCode = StatusCodes.Status500InternalServerError
                });
            }
        }