Example #1
0
        /// <summary>
        /// The purpose of that method is to generate "On hold queue" process result in a unified way through all the
        /// verifications of the withdrawal menu.
        /// </summary>
        /// <param name="withdrawalId"></param>
        /// <returns></returns>
        public OfflineWithdrawalHistory GetOnHoldQueueRecord(Guid withdrawalId)
        {
            var wdRecordHistory = _repository.OfflineWithdrawalHistories
                                  .Where(o => o.OfflineWithdrawalId == withdrawalId)
                                  .OrderByDescending(o => o.DateCreated).ToList();

            OfflineWithdrawalHistory match = null, beforeMatch = null;

            for (int i = 0; i < wdRecordHistory.Count - 2; i++)
            {
                if (wdRecordHistory[i].Action == WithdrawalStatus.Verified &&
                    wdRecordHistory[i + 1].Action != WithdrawalStatus.Reverted)
                {
                    match       = Mapper.Map <OfflineWithdrawalHistory>(wdRecordHistory[i]);
                    beforeMatch = Mapper.Map <OfflineWithdrawalHistory>(wdRecordHistory[i + 1]);

                    break;
                }
            }

            return(beforeMatch != null ? match : null);
        }
        private object GenerateWithdawalInfoResponse(Guid id,
                                                     OfflineWithdraw withdrawal,
                                                     OfflineWithdrawalHistory verificationQueue,
                                                     OfflineWithdrawalHistory onHoldQueue)
        {
            var response = new
            {
                BaseInfo = new
                {
                    Licensee = withdrawal.PlayerBankAccount.Bank.Brand.LicenseeName,
                    Brand    = withdrawal.PlayerBankAccount.Bank.Brand.Name,
                    withdrawal.PlayerBankAccount.Player.Username,
                    ReferenceCode = withdrawal.TransactionNumber,
                    Status        =
                        withdrawal.Status == WithdrawalStatus.AutoVerificationFailed
                            ? WithdrawalStatus.New.ToString()
                            : withdrawal.Status.ToString(),
                    InternalAccount = "no", //TODO: wtf
                    Currency        = withdrawal.PlayerBankAccount.Player.CurrencyCode,
                    PaymentMethod   = withdrawal.PaymentMethod.ToString(),
                    Amount          = withdrawal.Amount.ToString(CultureInfo.InvariantCulture),
                    Submitted       = withdrawal.CreatedBy,
                    DateSubmitted   = Format.FormatDate(withdrawal.Created)
                },
                BankInformation = new
                {
                    withdrawal.PlayerBankAccount.Bank.BankName,
                    BankAccountName   = withdrawal.PlayerBankAccount.AccountName,
                    BankAccountNumber = withdrawal.PlayerBankAccount.AccountNumber,
                    withdrawal.PlayerBankAccount.Branch,
                    withdrawal.PlayerBankAccount.SwiftCode,
                    withdrawal.PlayerBankAccount.Address,
                    withdrawal.PlayerBankAccount.City,
                    withdrawal.PlayerBankAccount.Province
                },
                ProcessInformation = new
                {
                    AutoVerification = new
                    {
                        HasAutoVerification = withdrawal.AutoVerificationCheckStatus != null,
                        Status =
                            withdrawal.AutoVerificationCheckStatus != null
                                ? withdrawal.AutoVerificationCheckStatus.ToString()
                                : "",
                        Date =
                            withdrawal.AutoVerificationCheckDate != null
                                ? Format.FormatDate(withdrawal.AutoVerificationCheckDate)
                                : ""
                    },
                    RiskLevel = new
                    {
                        HasRiskLevel = withdrawal.RiskLevelStatus != null,
                        Status       =
                            withdrawal.RiskLevelStatus != null
                                ? withdrawal.RiskLevelStatus.ToString()
                                : "",
                        Date =
                            withdrawal.RiskLevelCheckDate != null
                                ? Format.FormatDate(withdrawal.RiskLevelCheckDate)
                                : ""
                    },
                    VerificationQueue = new
                    {
                        HasResult = verificationQueue != null,
                        Result    = verificationQueue != null?verificationQueue.Action.ToString() : null,
                                        HandledBy   = verificationQueue != null ? verificationQueue.Username : null,
                                        DateHandled = verificationQueue != null?Format.FormatDate(verificationQueue.DateCreated) : null
                    },
                    OnHoldQueue = new
                    {
                        HasResult = onHoldQueue != null,
                        Result    = onHoldQueue != null?onHoldQueue.Action.ToString() : null,
                                        HandledBy   = onHoldQueue != null ? onHoldQueue.Username : null,
                                        DateHandled = onHoldQueue != null?Format.FormatDate(onHoldQueue.DateCreated) : null
                    }
                },
                Remarks = new
                {
                    AdminRemarks  = GetWithdrawalHistoryFormattedRemakrs(id, true),
                    PlayerRemarks = GetWithdrawalHistoryFormattedRemakrs(id)
                },
                Officer = _actorInfoProvider.Actor.UserName
            };

            return(response);
        }