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));
            }
        }
示例#2
0
        public async Task <IActionResult> GetUtilitys([FromQuery] UtilityParameter utilityParameter)
        {
            var result = await utilityService.GetUtilitys(utilityParameter);

            return(StatusCode((int)result.Code, result.Value));
        }