Beispiel #1
0
        /// <summary>
        /// Gets the WalletAdjustment.
        /// </summary>
        /// <param name="walletAdjustmentParameter">The WalletAdjustment parameter request.</param>
        /// <returns></returns>
        //public async Task<APIResponse> GetAllWalletAdjustment(WalletAdjustmentParameter walletAdjustmentParameter)
        //{
        //    try
        //    {
        //        string serializedWalletAdjustment;

        //        List<WalletAdjustmentResponse> walletAdjustment;

        //        var encodedWalletAdjustment = await distributedCache.GetAsync(WalletServiceOperation.GetWalletCacheName);

        //        if (encodedWalletAdjustment != null)
        //        {
        //            serializedWalletAdjustment = Encoding.UTF8.GetString(encodedWalletAdjustment);
        //            walletAdjustment = JsonConvert.DeserializeObject<List<WalletAdjustmentResponse>>(serializedWalletAdjustment);
        //        }
        //        else
        //        {
        //            var client = httpClientFactory.CreateClient(WalletServiceOperation.serviceName);

        //            UriBuilder url = new UriBuilder(servicesConfig.Wallet + WalletServiceOperation.GetAllWalletAdjustment());
        //            url.Query = QueryStringHelper.ConvertToQueryString(walletAdjustmentParameter);

        //            var response = await client.GetAsync(url.ToString());
        //            walletAdjustment = JsonConvert.DeserializeObject<List<WalletAdjustmentResponse>>(await response.Content.ReadAsStringAsync());

        //            serializedWalletAdjustment = JsonConvert.SerializeObject(walletAdjustment);
        //            encodedWalletAdjustment = Encoding.UTF8.GetBytes(serializedWalletAdjustment);
        //            var options = new DistributedCacheEntryOptions()
        //                            .SetSlidingExpiration(TimeSpan.FromMinutes(1))
        //                            .SetAbsoluteExpiration(DateTime.Now.AddHours(1));

        //            await distributedCache.SetAsync(WalletServiceOperation.GetWalletCacheName, encodedWalletAdjustment, options);
        //        }

        //        return new APIResponse(walletAdjustment, HttpStatusCode.OK);
        //    }
        //    catch (Exception ex)
        //    {
        //        logger.Error(ex, "Exception in method 'GetAllWalletAdjustment()'");
        //        var exMessage = ex.InnerException != null ? ex.InnerException.Message : ex.Message;
        //        return new APIResponse(exMessage, HttpStatusCode.InternalServerError);
        //    }
        //}
        public async Task <APIResponse> GetAllWalletAdjustment(WalletAdjustmentParameter walletAdjustmentParameter)
        {
            try
            {
                var client = httpClientFactory.CreateClient(WalletServiceOperation.serviceName);

                UriBuilder url = new UriBuilder(servicesConfig.Wallet + WalletServiceOperation.GetAllWalletAdjustment());
                url.Query = QueryStringHelper.ConvertToQueryString(walletAdjustmentParameter);
                var response = await client.GetAsync(url.ToString());

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

                return(new APIResponse(response.StatusCode));
            }
            catch (Exception ex)
            {
                logger.Error(ex, "Exception in method 'GetAllWalletAdjustment()'");
                var exMessage = ex.InnerException != null ? ex.InnerException.Message : ex.Message;
                return(new APIResponse(exMessage, HttpStatusCode.InternalServerError));
            }
        }
        public async Task <IActionResult> GetAllWalletAdjustment([FromQuery] WalletAdjustmentParameter walletAdjustmentParameter)
        {
            var getAllWalletAdjustmentQuery = new GetAllWalletAdjustmentQuery(walletAdjustmentParameter);

            var result = await mediator.Send(getAllWalletAdjustmentQuery);

            return(StatusCode((int)result.Code, result.Value));
        }
Beispiel #3
0
        /// <summary>
        /// Gets all Wallet Adjustment.
        /// </summary>
        /// <param name="walletAdjustmentParameter">The Wallet Adjustment parameters.</param>
        /// <returns></returns>
        //public async Task<List<Walletadjustment>> GetAllWalletAdjustment(WalletAdjustmentParameter walletAdjustmentParameter)
        //{
        //    {
        //        var getWalletAdjustmentParams = new object[]
        //        {
        //            new MySqlParameter("@p_Value", walletAdjustmentParameter.Value),
        //            new MySqlParameter("@p_AdjustmentType", walletAdjustmentParameter.AdjustmentType),
        //            new MySqlParameter("@p_IsForVendor", walletAdjustmentParameter.IsForVendor)
        //        };

        //        var walletAdjustment = await FindAll("CALL SpSelectActiveWalletAdjustment(@p_Value,@p_AdjustmentType,@p_IsForVendor)", getWalletAdjustmentParams).ToListAsync();

        //        return walletAdjustment;
        //    }
        //}

        public async Task <List <WalletAdjustmentResponse> > GetAllWalletAdjustment(WalletAdjustmentParameter walletAdjustmentParameter)
        {
            var walletadjustments = FindByCondition(x => x.Active == Convert.ToInt16(true)).OrderBy(x => x.VendorId)
                                    .ProjectTo <WalletAdjustmentResponse>(mapper.ConfigurationProvider);

            SearchByAdjustmentTypeOrVendorId(ref walletadjustments, walletAdjustmentParameter);
            var result = await walletadjustments.ToListAsync();

            return(result);
        }
Beispiel #4
0
        public async Task <IActionResult> GetAllWalletAdjustment([FromQuery] WalletAdjustmentParameter walletAdjustmentParameter)
        {
            var result = await walletAdjustmentService.GetAllWalletAdjustment(walletAdjustmentParameter);

            return(StatusCode((int)result.Code, result.Value));
        }
Beispiel #5
0
        private void SearchByAdjustmentTypeOrVendorId(ref IQueryable <WalletAdjustmentResponse> walletadjustments, WalletAdjustmentParameter walletAdjustmentParameter)
        {
            if (walletAdjustmentParameter.AdjustmentType > 0)
            {
                walletadjustments = walletadjustments.Where(x => x.AdjustmentType == walletAdjustmentParameter.AdjustmentType).OrderBy(x => x.VendorId);
            }

            if (walletAdjustmentParameter.Value > 0)
            {
                if (walletAdjustmentParameter.IsForVendor == true)
                {
                    walletadjustments = walletadjustments.Where(x => x.VendorId.Equals(walletAdjustmentParameter.Value)).OrderBy(x => x.VendorId);
                }
                else
                {
                    walletadjustments = walletadjustments.Where(x => x.Id.Equals(walletAdjustmentParameter.Value)).OrderBy(x => x.VendorId);
                }
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="GetAllWalletAdjustmentQuery"/> class.
 /// </summary>
 /// <param name="walletAdjustmentParameter">The Wallet Adjustment parameters.</param>
 public GetAllWalletAdjustmentQuery(WalletAdjustmentParameter walletAdjustmentParameter)
 {
     WalletAdjustmentParameter = walletAdjustmentParameter;
 }