예제 #1
0
        public int MemberRequestWithdrawalCrypto(long _MemberSrno, decimal WithdrawalAmount, string ToAddress, decimal Rate, string Currency)
        {
            try
            {
                var WithdrawalRequest = new MstWithdraw
                {
                    MemberSrno      = _MemberSrno,
                    Status          = 0,
                    RequestDate     = DateTime.Now,
                    WithdrawAmount  = WithdrawalAmount,
                    TransactionType = 1,
                    ToAddress       = ToAddress,
                    Rate            = Rate,
                    Currency        = Currency,
                };

                var CurrentUserWalletInfo = _db.MstUserWallet.Where(x => x.MemberSrno == _MemberSrno).FirstOrDefault();

                if (WithdrawalAmount > CurrentUserWalletInfo.CashCredit)
                {
                    return(Models_General.ERR_WALLET_CREDIT_INSUFFICIENT);
                }

                if (CurrentUserWalletInfo.TurnoverAmount > 0)
                {
                    return(Models_General.ERR_WALLET_TURNOVER_CLEAR);
                }

                CurrentUserWalletInfo.CashCredit             = CurrentUserWalletInfo.CashCredit - WithdrawalAmount;
                CurrentUserWalletInfo.PendingWithdrawAmount += WithdrawalAmount;

                _db.MstWithdraw.Add(WithdrawalRequest);
                _db.SaveChanges();
                return(Models_General.SUCC_CREATE_REQUEST_WITHDRAWAL);
            }
            catch (Exception ex)
            {
                var new_error = new LogErrorSystem
                {
                    Title           = "Member Request Withdrawal Crypto",
                    Details         = ex.Message + "/" + ex.StackTrace,
                    Context         = _accessor.ActionContext.HttpContext.Connection.RemoteIpAddress.ToString(),
                    CreatedDateTime = DateTime.Now,
                };
                _db.LogErrorSystem.Add(new_error);
                _db.SaveChanges();
                return(Models_General.ERR_SERVER_BUSY_INTERNAL_ERROR);
            }
        }
예제 #2
0
        public int MemberRequestWithdrawalOnlineBanking(long _MemberSrno, decimal WithdrawalAmount, long MemberBankSrno, string Currency)
        {
            try
            {
                var UserBankDetails = _db.MstUserBank.Where(x => x.Srno == MemberBankSrno).FirstOrDefault();

                if (UserBankDetails != null)
                {
                    var BankDetails = _db.MstBank.Where(x => x.Srno == UserBankDetails.BankSrno).FirstOrDefault();

                    if (BankDetails != null)
                    {
                        var WithdrawalRequest = new MstWithdraw
                        {
                            MemberSrno        = _MemberSrno,
                            BankName          = BankDetails.BankName,
                            BankCardNo        = UserBankDetails.BankCardNo,
                            BankAccountHolder = UserBankDetails.BankAccountHolder,
                            BankCode          = BankDetails.BankCode,
                            Status            = 0,
                            RequestDate       = DateTime.Now,
                            WithdrawAmount    = WithdrawalAmount,
                            TransactionType   = 0,
                            Currency          = Currency,
                        };

                        var CurrentUserWalletInfo = _db.MstUserWallet.Where(x => x.MemberSrno == _MemberSrno).FirstOrDefault();

                        if (WithdrawalAmount > CurrentUserWalletInfo.CashCredit)
                        {
                            return(Models_General.ERR_WALLET_CREDIT_INSUFFICIENT);
                        }

                        if (CurrentUserWalletInfo.TurnoverAmount > 0)
                        {
                            return(Models_General.ERR_WALLET_TURNOVER_CLEAR);
                        }

                        CurrentUserWalletInfo.CashCredit             = CurrentUserWalletInfo.CashCredit - WithdrawalAmount;
                        CurrentUserWalletInfo.PendingWithdrawAmount += WithdrawalAmount;

                        _db.MstWithdraw.Add(WithdrawalRequest);
                        _db.SaveChanges();
                        return(Models_General.SUCC_CREATE_REQUEST_WITHDRAWAL);
                    }
                    else
                    {
                        return(Models_General.ERR_BANK_INFO_NOT_MATCH);
                    }
                }
                return(Models_General.ERR_BANK_INFO_NOT_MATCH);
            }
            catch (Exception ex)
            {
                var new_error = new LogErrorSystem
                {
                    Title           = "Member Request Withdrawal Online Banking",
                    Details         = ex.Message + "/" + ex.StackTrace,
                    Context         = _accessor.ActionContext.HttpContext.Connection.RemoteIpAddress.ToString(),
                    CreatedDateTime = DateTime.Now,
                };
                _db.LogErrorSystem.Add(new_error);
                _db.SaveChanges();
                return(Models_General.ERR_SERVER_BUSY_INTERNAL_ERROR);
            }
        }