/// <summary> /// Gets the PaymentBook. /// </summary> /// <param name="paymentBookParameter">The PaymentBook parameter request.</param> /// <returns></returns> //public async Task<APIResponse> GetAllPaymentBook(PaymentBookParameter paymentBookParameter) //{ // try // { // string serializedPaymentBook; // List<PaymentBookResponse> paymentBook; // var encodedPaymentBook = await distributedCache.GetAsync(WalletServiceOperation.GetWalletCacheName); // if (encodedPaymentBook != null) // { // serializedPaymentBook = Encoding.UTF8.GetString(encodedPaymentBook); // paymentBook = JsonConvert.DeserializeObject<List<PaymentBookResponse>>(serializedPaymentBook); // } // else // { // var client = httpClientFactory.CreateClient(WalletServiceOperation.serviceName); // UriBuilder url = new UriBuilder(servicesConfig.Wallet + WalletServiceOperation.GetAllPaymentBook()); // url.Query = QueryStringHelper.ConvertToQueryString(paymentBookParameter); // var response = await client.GetAsync(url.ToString()); // paymentBook = JsonConvert.DeserializeObject<List<PaymentBookResponse>>(await response.Content.ReadAsStringAsync()); // serializedPaymentBook = JsonConvert.SerializeObject(paymentBook); // encodedPaymentBook = Encoding.UTF8.GetBytes(serializedPaymentBook); // var options = new DistributedCacheEntryOptions() // .SetSlidingExpiration(TimeSpan.FromMinutes(1)) // .SetAbsoluteExpiration(DateTime.Now.AddHours(1)); // await distributedCache.SetAsync(WalletServiceOperation.GetWalletCacheName, encodedPaymentBook, options); // } // return new APIResponse(paymentBook, HttpStatusCode.OK); // } // catch (Exception ex) // { // logger.Error(ex, "Exception in method 'GetAllPaymentBook()'"); // var exMessage = ex.InnerException != null ? ex.InnerException.Message : ex.Message; // return new APIResponse(exMessage, HttpStatusCode.InternalServerError); // } //} public async Task <APIResponse> GetAllPaymentBook(PaymentBookParameter paymentBookParameter) { try { var client = httpClientFactory.CreateClient(WalletServiceOperation.serviceName); UriBuilder url = new UriBuilder(servicesConfig.Wallet + WalletServiceOperation.GetAllPaymentBook()); url.Query = QueryStringHelper.ConvertToQueryString(paymentBookParameter); var response = await client.GetAsync(url.ToString()); if (response.IsSuccessStatusCode) { var paymentBook = JsonConvert.DeserializeObject <List <PaymentBookResponse> >(await response.Content.ReadAsStringAsync()); return(new APIResponse(paymentBook, HttpStatusCode.OK)); } return(new APIResponse(response.StatusCode)); } catch (Exception ex) { logger.Error(ex, "Exception in method 'GetAllPaymentBook()'"); var exMessage = ex.InnerException != null ? ex.InnerException.Message : ex.Message; return(new APIResponse(exMessage, HttpStatusCode.InternalServerError)); } }
public async Task <IActionResult> GetAllPaymentBook([FromQuery] PaymentBookParameter paymentBookParameter) { var result = await paymentBookService.GetAllPaymentBook(paymentBookParameter); return(StatusCode((int)result.Code, result.Value)); }