public bool CheckConditionRewardByDatenUserID(DateTime pStartDate, string pUserID) { try { var countReward = 0; var transactionOptions = new System.Transactions.TransactionOptions(); transactionOptions.IsolationLevel = System.Transactions.IsolationLevel.ReadUncommitted; using (var transactionScope = new System.Transactions.TransactionScope(System.Transactions.TransactionScopeOption.Required, transactionOptions)) { countReward = new TransactionQueryBuilder(new WalletEntities()).CountRewardTransactionByDatenUserID(pStartDate, pUserID); } if (countReward > EwalletConstant.LimitTopupExtraPerUser) { return(false); } else { return(true); } } catch (Exception ex) { var logWallet = new LogWallet(); logWallet.Log(MethodBase.GetCurrentMethod(), "", ex, ""); return(false); } }
public int CountWithdrawTime(string pUserID) { int?WithdrawalTime = 0; using (var TransactionBuilder = new TransactionQueryBuilder(new WalletEntities())) { WithdrawalTime = new TransactionQueryBuilder(new WalletEntities()).CountWithdrawTimeByUserIDnDateTimenCurrency(pUserID, DateTime.Now, DateTime.Now.AddMonths(-1)); } return(WithdrawalTime.Value); }
public List <Transaction> GetTransactionLstTownBusByCarIDnDateTime(TripsRequestTownBus request) { var transactionlst = new List <Transaction>(); try { transactionlst = new TransactionQueryBuilder(new WalletEntities()) .GetTransBySource("TownBus") .FromDate(DateTime.Parse(request.StartDateTimeRange.Replace("T", " "))) .ToDate(DateTime.Parse(request.EndDateTimeRange.Replace("T", " "))).ToList(); } catch (Exception ex) { var logWallet = new LogWallet(); logWallet.Log(MethodBase.GetCurrentMethod(), request.CarId, ex, ""); return(null); } return(transactionlst); }
public List <Transaction> GetTransTopupWithoutVerified() { var Tran = new List <Transaction>(); try { var transactionOptions = new System.Transactions.TransactionOptions(); transactionOptions.IsolationLevel = System.Transactions.IsolationLevel.ReadUncommitted; using (var transactionScope = new System.Transactions.TransactionScope(System.Transactions.TransactionScopeOption.Required, transactionOptions)) { Tran = new TransactionQueryBuilder(new WalletEntities()).GetTransTopup().ToList(); } return(Tran); } catch (Exception ex) { var logWallet = new LogWallet(); Task.Factory.StartNew(() => logWallet.Log(MethodBase.GetCurrentMethod(), "", ex, "")); return(Tran); } }
public List <Transaction> GetTranTownBusnWithdrawByUserIDNoVerify(string pUserID, string pCurrencyCode) { var Tran = new List <Transaction>(); try { var transactionOptions = new System.Transactions.TransactionOptions(); transactionOptions.IsolationLevel = System.Transactions.IsolationLevel.ReadUncommitted; using (var transactionScope = new System.Transactions.TransactionScope(System.Transactions.TransactionScopeOption.Required, transactionOptions)) { Tran = new TransactionQueryBuilder(new WalletEntities()).GetTranTownBusnWithdrawByUserIDNoVerify(pUserID, pCurrencyCode).ToList(); } return(Tran); } catch (Exception ex) { var logWallet = new LogWallet(); Task.Factory.StartNew(() => logWallet.Log(MethodBase.GetCurrentMethod(), "", ex, "")); return(Tran); } }
public Transaction GetWalletTranByTranID(string TranID) { var Tran = new Transaction(); try { var transactionOptions = new System.Transactions.TransactionOptions(); transactionOptions.IsolationLevel = System.Transactions.IsolationLevel.ReadUncommitted; using (var transactionScope = new System.Transactions.TransactionScope(System.Transactions.TransactionScopeOption.Required, transactionOptions)) { Tran = new TransactionQueryBuilder(new WalletEntities()).GetTranByTranID(TranID).FirstOrDefault(); } return(Tran); } catch (Exception ex) { var logWallet = new LogWallet(); Task.Factory.StartNew(() => logWallet.Log(MethodBase.GetCurrentMethod(), TranID, ex, "")); return(Tran); } }
public Transaction GetTranSinceFirstStation(string userID, int tripID, string tranID, string carID) { Transaction tran = new Transaction(); try { var transactionlst = new TransactionQueryBuilder(new WalletEntities()) .GetTransBySource("TownBus") .GetTranByTranID(tranID) .GetPendingTransByUserIDnStatus("NULL", userID) .ToList(); tran = transactionlst.Where(tr => tr.Remarks.Split('|')[2].Contains(carID) && tr.Remarks.Split('|')[0].Contains(tripID.ToString()) && tr.Remarks.Contains("TOWNBUS-FULLROUTE")).FirstOrDefault(); } catch (Exception ex) { var logWallet = new LogWallet(); logWallet.Log(MethodBase.GetCurrentMethod(), userID, ex, ""); // return null; } return(tran); }
public bool IsExsistListPendingTransactionByUserID(string userID) { var IsExsist = false; try { var transactionOptions = new System.Transactions.TransactionOptions(); transactionOptions.IsolationLevel = System.Transactions.IsolationLevel.ReadUncommitted; using (var transactionScope = new System.Transactions.TransactionScope(System.Transactions.TransactionScopeOption.Required, transactionOptions)) { IsExsist = new TransactionQueryBuilder(new WalletEntities()) .IsExistPendingTransByUserIDnStatus("NULL", userID, "TownBus"); } } catch (Exception ex) { var logWallet = new LogWallet(); logWallet.Log(MethodBase.GetCurrentMethod(), userID, ex, ""); return(false); } return(IsExsist); }
public Transaction GetTranByTranID(string pTranID) { var TransactionQueryBuilder = new TransactionQueryBuilder(CurrentCountryContext); return(TransactionQueryBuilder.GetTranByTranID(pTranID).FirstOrDefault()); }
public decimal CalculationFeeC(string pUserID, string currencyCode, decimal amountWithdrawalCurrent, decimal balanceAmount, ref string percent) { decimal feeC = 0; //percent = "(0%)"; //var isExistTopupWithin60Days = new TransactionQueryBuilder(new WalletEntities()).CheckTopupByUserIDnDateTimenCurrency(pUserID, DateTime.Now, DateTime.Now.AddDays(-60), currencyCode); //if (isExistTopupWithin60Days) //{ // feeC = amountWithdrawalCurrent * (decimal)0.03; // percent = "(3%)"; //} //else //{ // var isExistTopupWithin120Days = new TransactionQueryBuilder(new WalletEntities()).CheckTopupByUserIDnDateTimenCurrency(pUserID, DateTime.Now, DateTime.Now.AddDays(-120), currencyCode); // if (isExistTopupWithin120Days) // { // feeC = amountWithdrawalCurrent * (decimal)0.02; // percent = "(2%)"; // } //} percent = ""; var historyTopupTranOfUser = new TransactionQueryBuilder(new WalletEntities()).GetHistoryDebitByUserIDnCurrency(pUserID, currencyCode).ToList().Select(x => new ItemTran { Amount = x.Source_Amount, CreateDate = x.CreateDate }).ToList(); var historyWithdrawTranOfUser = new TransactionQueryBuilder(new WalletEntities()).GetHistoryCreditByUserIDnCurrency(pUserID, currencyCode).ToList().Select(x => new ItemTran { Amount = x.Source_Amount, CreateDate = x.CreateDate }).ToList(); decimal amountLeft = 0; DateTime currentTopupTime = new DateTime(); var amountWithrawlLeftCurrent = 0.0M; var timeWithdrawalCurrent = DateTime.Now; var sumFeeC = 0.0M; foreach (var itemWithdraw in historyWithdrawTranOfUser.OrderBy(x => x.CreateDate)) { int i = 0; amountLeft = FIFO(historyTopupTranOfUser, itemWithdraw.Amount, i, amountLeft, itemWithdraw.CreateDate, out currentTopupTime); } if (amountLeft < 0) { if (historyTopupTranOfUser[0].CreateDate == currentTopupTime) { historyTopupTranOfUser.RemoveAt(0); } historyTopupTranOfUser.Insert(0, new ItemTran { Amount = Math.Abs(amountLeft), CreateDate = currentTopupTime }); } foreach (var itemtopup in historyTopupTranOfUser.OrderBy(x => x.CreateDate).ToList()) { //calculate for current withdrawal amount if (Math.Abs((timeWithdrawalCurrent - itemtopup.CreateDate.Value).Days) < 61) { var amout = amountWithdrawalCurrent - itemtopup.Amount.Value; if (amout <= 0) { sumFeeC += amountWithdrawalCurrent * (decimal)0.03; amountWithdrawalCurrent = 0; break; } else //sufficient topup amount { sumFeeC += (itemtopup.Amount == 0 ? amountWithdrawalCurrent : itemtopup.Amount.Value) * (decimal)0.03; amountWithrawlLeftCurrent = amout; } } else if (Math.Abs((timeWithdrawalCurrent - itemtopup.CreateDate.Value).Days) < 121) { var amout = amountWithdrawalCurrent - itemtopup.Amount.Value; if (amout <= 0) { sumFeeC += amountWithdrawalCurrent * (decimal)0.02; amountWithdrawalCurrent = 0; break; } else //insufficient topup amount { sumFeeC += (itemtopup.Amount == 0 ? amountWithdrawalCurrent : itemtopup.Amount.Value) * (decimal)0.02; amountWithrawlLeftCurrent = amout; } } else { amountWithrawlLeftCurrent = amountWithdrawalCurrent - itemtopup.Amount.Value; } currentTopupTime = itemtopup.CreateDate.Value; amountWithdrawalCurrent = amountWithrawlLeftCurrent; if (amountWithrawlLeftCurrent <= 0) { break; } } if (amountWithdrawalCurrent > 0) { if (Math.Abs((timeWithdrawalCurrent - currentTopupTime).Days) < 61) { sumFeeC += amountWithrawlLeftCurrent * (decimal)0.03; } else if (Math.Abs((timeWithdrawalCurrent - currentTopupTime).Days) < 121) { sumFeeC += amountWithrawlLeftCurrent * (decimal)0.02; } } feeC = sumFeeC; return(Math.Round(feeC, 2)); }