/// <summary> /// Gets the WalletStatus. /// </summary> /// <param name="walletStatusParameter">The WalletStatus parameter request.</param> /// <returns></returns> //public async Task<APIResponse> GetAllWalletStatus(WalletStatusParameter walletStatusParameter) //{ // try // { // string serializedWalletStatus; // List<WalletStatusResponse> walletStatus; // var encodedWalletStatus = await distributedCache.GetAsync(WalletServiceOperation.GetWalletCacheName); // if (encodedWalletStatus != null) // { // serializedWalletStatus = Encoding.UTF8.GetString(encodedWalletStatus); // walletStatus = JsonConvert.DeserializeObject<List<WalletStatusResponse>>(serializedWalletStatus); // } // else // { // var client = httpClientFactory.CreateClient(WalletServiceOperation.serviceName); // UriBuilder url = new UriBuilder(servicesConfig.Wallet + WalletServiceOperation.GetAllWalletStatus()); // url.Query = QueryStringHelper.ConvertToQueryString(walletStatusParameter); // var response = await client.GetAsync(url.ToString()); // walletStatus = JsonConvert.DeserializeObject<List<WalletStatusResponse>>(await response.Content.ReadAsStringAsync()); // serializedWalletStatus = JsonConvert.SerializeObject(walletStatus); // encodedWalletStatus = Encoding.UTF8.GetBytes(serializedWalletStatus); // var options = new DistributedCacheEntryOptions() // .SetSlidingExpiration(TimeSpan.FromMinutes(1)) // .SetAbsoluteExpiration(DateTime.Now.AddHours(1)); // await distributedCache.SetAsync(WalletServiceOperation.GetWalletCacheName, encodedWalletStatus, options); // } // return new APIResponse(walletStatus, HttpStatusCode.OK); // } // catch (Exception ex) // { // logger.Error(ex, "Exception in method 'GetAllWalletStatus()'"); // var exMessage = ex.InnerException != null ? ex.InnerException.Message : ex.Message; // return new APIResponse(exMessage, HttpStatusCode.InternalServerError); // } //} public async Task <APIResponse> GetAllWalletStatus(WalletStatusParameter walletStatusParameter) { try { var client = httpClientFactory.CreateClient(WalletServiceOperation.serviceName); UriBuilder url = new UriBuilder(servicesConfig.Wallet + WalletServiceOperation.GetAllWalletStatus()); url.Query = QueryStringHelper.ConvertToQueryString(walletStatusParameter); var response = await client.GetAsync(url.ToString()); if (response.IsSuccessStatusCode) { var walletStatus = JsonConvert.DeserializeObject <List <WalletStatusResponse> >(await response.Content.ReadAsStringAsync()); return(new APIResponse(walletStatus, HttpStatusCode.OK)); } return(new APIResponse(response.StatusCode)); } catch (Exception ex) { logger.Error(ex, "Exception in method 'GetAllWalletStatus()'"); var exMessage = ex.InnerException != null ? ex.InnerException.Message : ex.Message; return(new APIResponse(exMessage, HttpStatusCode.InternalServerError)); } }
public async Task <IActionResult> GetAllWalletStatus([FromQuery] WalletStatusParameter walletStatusParameter) { var getAllWalletStatusQuery = new GetAllWalletStatusQuery(walletStatusParameter); var result = await mediator.Send(getAllWalletStatusQuery); return(StatusCode((int)result.Code, result.Value)); }
/// <summary> /// Gets all Wallet Status. /// </summary> /// <param name="walletsStatusParameter">The Wallet Status parameters.</param> /// <returns></returns> //public async Task<List<Walletstatus>> GetAllWalletStatus(WalletStatusParameter walletsStatusParameter) //{ // { // var getWalletStatusParams = new object[] { new MySqlParameter("@p_Value", walletsStatusParameter.Value), new MySqlParameter("@p_IsForWallet", walletsStatusParameter.IsForWallet) }; // var walletStatus = await FindAll("CALL SpSelectActiveWalletStatus(@p_Value,@p_IsForWallet)", getWalletStatusParams).ToListAsync(); // return walletStatus; // } //} public async Task <List <WalletStatusResponse> > GetAllWalletStatus(WalletStatusParameter walletsStatusParameter) { var walletstatus = FindByCondition(x => x.Active == Convert.ToInt16(true)).OrderBy(x => x.WalletId) .ProjectTo <WalletStatusResponse>(mapper.ConfigurationProvider); SearchWalletStatusById(ref walletstatus, walletsStatusParameter); var result = await walletstatus.ToListAsync(); return(result); }
private void SearchWalletStatusById(ref IQueryable <WalletStatusResponse> walletstatus, WalletStatusParameter walletsStatusParameter) { if (walletsStatusParameter.Value > 0) { if (walletsStatusParameter.IsForWallet == true) { walletstatus = walletstatus.Where(x => x.WalletId.Equals(walletsStatusParameter.Value)).OrderBy(x => x.WalletId); } else { walletstatus = walletstatus.Where(x => x.Id.Equals(walletsStatusParameter.Value)).OrderBy(x => x.WalletId); } } }
/// <summary> /// Initializes a new instance of the <see cref="GetAllWalletStatusQuery"/> class. /// </summary> /// <param name="walletStatusParameter">The Wallet Status parameters.</param> public GetAllWalletStatusQuery(WalletStatusParameter walletStatusParameter) { WalletStatusParameter = walletStatusParameter; }
public async Task <IActionResult> GetAllWalletStatus([FromQuery] WalletStatusParameter walletStatusParameter) { var result = await walletStatusService.GetAllWalletStatus(walletStatusParameter); return(StatusCode((int)result.Code, result.Value)); }