예제 #1
0
        public async Task <APIResponse> GetUtilitys(UtilityParameter utilityParameter)
        {
            try
            {
                var client = httpClientFactory.CreateClient(VendorServiceOperation.serviceName);

                UriBuilder url = new UriBuilder(servicesConfig.Vendor + VendorServiceOperation.Getutilitys());
                url.Query = QueryStringHelper.ConvertToQueryString(utilityParameter);

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

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

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