Exemplo n.º 1
0
        public async Task <APIResponse> GetEventDetailsById(EventVendorParameters eventVendorParameters)
        {
            try
            {
                string serializedStories;
                // List<AssetResponse> stories;

                /* var encodedStories = await distributedCache.GetAsync(BlogServiceOperation.GetStoriesCacheName);
                 *
                 * if (encodedStories != null)
                 * {
                 *   serializedStories = Encoding.UTF8.GetString(encodedStories);
                 *   stories = JsonConvert.DeserializeObject<List<StoryResponse>>(serializedStories);
                 * }
                 * else
                 * {*/
                var client = httpClientFactory.CreateClient(VendorServiceOperation.serviceName);

                UriBuilder url = new UriBuilder(servicesConfig.Blog + VendorServiceOperation.GetEventDetailsById());
                url.Query = QueryStringHelper.ConvertToQueryString(eventVendorParameters);

                var response = await client.GetAsync(url.ToString());

                var eventResponse = JsonConvert.DeserializeObject <EventResponse>(await response.Content.ReadAsStringAsync());

                serializedStories = JsonConvert.SerializeObject(eventResponse);

                /* encodedStories = Encoding.UTF8.GetBytes(serializedStories);
                 * var options = new DistributedCacheEntryOptions()
                 *               .SetSlidingExpiration(TimeSpan.FromMinutes(1))
                 *               .SetAbsoluteExpiration(DateTime.Now.AddHours(1));
                 *
                 * await distributedCache.SetAsync(VendorServiceOperation.GetStoriesCacheName, encodedStories, options);
                 * }*/

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