public IQueryable <PlayerPaymentAmount> GetPlayerWithdrawalAmount(GetPlayerPaymentAmountRequest request) { var query = _repository.Players .Include(x => x.Brand) .Include(x => x.PlayerPaymentLevel); query = GetPlayerFilterQueryable(request, query); var withdrawalQuery = GetwithdrawalFilterQueryable(request); var resultQuery = query.Select(obj => new PlayerPaymentAmount { PlayerId = obj.Id, LicenseeName = obj.Brand.LicenseeName, BrandId = obj.BrandId, BrandName = obj.Brand.Name, Username = obj.Username, FullName = obj.FirstName + " " + obj.LastName, PaymentLevelName = obj.PlayerPaymentLevel.PaymentLevel.Name, PaymentLevelId = obj.PlayerPaymentLevel.PaymentLevel.Id, Amount = withdrawalQuery.Where(p => p.PlayerBankAccount.Player.Id == obj.Id).Sum(x => (decimal?)x.Amount) ?? 0, Currency = obj.CurrencyCode }); return(resultQuery); }
private GetPlayerPaymentAmountRequest HandleSearchPackage(SearchPackage searchPackage) { var queryFilter = new GetPlayerPaymentAmountRequest(); foreach (var rule in searchPackage.AdvancedFilter.Rules) { switch (rule.Field) { case "TransactionType": ParseTransactionTypeRule(searchPackage, rule, queryFilter); break; case "ApproveDate": ParseApproveDateRule(searchPackage, rule, queryFilter); break; case "PaymentMethod": ParsePaymentMethodRule(searchPackage, rule, queryFilter); break; case "PlayerStatus": ParsePlayerStatusRule(searchPackage, rule, queryFilter); break; } } return(queryFilter); }
private IQueryable <Player> GetPlayerFilterQueryable(GetPlayerPaymentAmountRequest request, IQueryable <Player> query) { var now = DateTimeOffset.Now; Expression <Func <Player, bool> > conditions = x => false; Expression <Func <Player, bool> > expIsActive = x => x.IsActive == request.IsActive; Expression <Func <Player, bool> > expTimeOut = x => x.IsTimeOut && x.TimeOutEndDate.Value > now; Expression <Func <Player, bool> > expSelfExculde = x => x.IsSelfExclude && x.SelfExcludeEndDate > now; bool queryActive = request.IsActive != request.IsInactive; bool queryTimeOut = request.IsTimeOut; bool querySelfExcluded = request.IsSelfExcluded; bool queryAll = (request.IsActive == request.IsInactive) && (request.IsActive); if (false == queryAll && (queryActive || queryTimeOut || querySelfExcluded)) { if (queryActive) { conditions = conditions.OrElse(expIsActive); } if (request.IsTimeOut) { conditions = conditions.OrElse(expTimeOut); } if (request.IsSelfExcluded) { conditions = conditions.OrElse(expSelfExculde); } //Expression<Func<Player, bool>> wherePredicate = Expression.Lambda<Func<Player, bool>>(conditions); query = query.Where(conditions); } return(query); }
private void ParseTransactionTypeRule(SearchPackage searchPackage, SingleFilter rule, GetPlayerPaymentAmountRequest queryFilter) { if (rule.Data == "Withdraw") { queryFilter.IsQueryDeposit = false; } searchPackage.AdvancedFilter.Remove(rule); }
private void ParsePaymentMethodRule(SearchPackage searchPackage, SingleFilter rule, GetPlayerPaymentAmountRequest queryFilter) { if (!string.IsNullOrEmpty(rule.Data)) { if (rule.Comparison == ComparisonOperator.@in || rule.Comparison == ComparisonOperator.eq) { queryFilter.PaymentMethods = ParseOptionsData(rule.Data); } } searchPackage.AdvancedFilter.Remove(rule); }
private void ParsePlayerStatusRule(SearchPackage searchPackage, SingleFilter rule, GetPlayerPaymentAmountRequest queryFilter) { if (!string.IsNullOrEmpty(rule.Data)) { if (rule.Comparison == ComparisonOperator.@in || rule.Comparison == ComparisonOperator.eq) { var options = ParseOptionsData(rule.Data); queryFilter.IsActive = options.Contains("Active"); queryFilter.IsInactive = options.Contains("Inactive"); queryFilter.IsTimeOut = options.Contains("Time-out"); queryFilter.IsSelfExcluded = options.Contains("Self-Excluded"); } } searchPackage.AdvancedFilter.Remove(rule); }
private void ParseApproveDateRule(SearchPackage searchPackage, SingleFilter rule, GetPlayerPaymentAmountRequest queryFilter) { if (!string.IsNullOrEmpty(rule.Data)) { DateTime date; DateTime.TryParse(rule.Data, out date); if (rule.Comparison == ComparisonOperator.ge) { queryFilter.DateApprovedStart = date; } else if (rule.Comparison == ComparisonOperator.lt) { queryFilter.DateApprovedEnd = date; } } searchPackage.AdvancedFilter.Remove(rule); }
private IQueryable <Core.Payment.Data.Deposit> GetDepositFilterQueryable(GetPlayerPaymentAmountRequest request) { var depositQuery = _repository.Deposits .Where(d => d.Status == OfflineDepositStatus.Approved.ToString()); if (request.DateApprovedStart.HasValue) { depositQuery = depositQuery.Where(d => d.DateApproved >= request.DateApprovedStart.Value); } if (request.DateApprovedEnd.HasValue) { depositQuery = depositQuery.Where(d => d.DateApproved < request.DateApprovedEnd.Value); } if (request.PaymentMethods.Count > 0) { depositQuery = depositQuery.Where(d => request.PaymentMethods.Contains(d.PaymentMethod)); } return(depositQuery); }
private IQueryable <Core.Payment.Data.OfflineWithdraw> GetwithdrawalFilterQueryable(GetPlayerPaymentAmountRequest request) { var withdrawalQuery = _repository.OfflineWithdraws .Where(d => d.Status == WithdrawalStatus.Approved); if (request.DateApprovedStart.HasValue) { withdrawalQuery = withdrawalQuery.Where(d => d.Approved >= request.DateApprovedStart.Value); } if (request.DateApprovedEnd.HasValue) { withdrawalQuery = withdrawalQuery.Where(d => d.Approved < request.DateApprovedEnd.Value); } return(withdrawalQuery); }