Пример #1
0
        public async Task <APIResponse> GetEventById(int eventId)
        {
            try
            {
                var client   = httpClientFactory.CreateClient(VendorServiceOperation.serviceName);
                var response = await client.GetAsync(servicesConfig.Vendor + VendorServiceOperation.GetEventById(eventId));

                if (response.IsSuccessStatusCode)
                {
                    var events = JsonConvert.DeserializeObject <APIResponse>(await response.Content.ReadAsStringAsync());
                    return(new APIResponse(events, HttpStatusCode.OK));
                }

                return(new APIResponse(response.StatusCode));
            }
            catch (Exception ex)
            {
                logger.Error(ex, "Exception in method 'GetEventById()'");
                var exMessage = ex.InnerException != null ? ex.InnerException.Message : ex.Message;
                return(new APIResponse(exMessage, HttpStatusCode.InternalServerError));
            }
        }