Exemplo n.º 1
0
        public static AjaxResponse ChangeStatus(string id, string selectedStatus, string ref_hash)
        {
            string DecryptedId = Classes.encryption.Decrypt(id);

            using (NpgsqlConnection conn = Classes.DB.InstBTCDB("instbtc"))
            {
                //Update Status
                bool updateResult = WithdrawalUtilities.UpdateCreditedStatus(conn, DecryptedId, selectedStatus, ref_hash);
                if (updateResult)
                {
                    if (selectedStatus == "Approved")
                    {
                        WithdrawalUtilities.UpdateUsdValueAmount(conn, DecryptedId);


                        var withdrawalData = WithdrawalUtilities.GetWithdrawal(conn, DecryptedId);

                        if (withdrawalData.TransactionId == -1 && withdrawalData.Status == "Approved")
                        {
                            var result = InsertTransaction(conn, DecryptedId, createTransferRecord: false);
                            if (result.ToString() != "Internal Error" && !string.IsNullOrEmpty(result.ToString()))
                            {
                                var updateWithdrawalTransaction = WithdrawalUtilities.UpdateTransactionId(conn, DecryptedId, Convert.ToInt32(result));

                                ToastrUtilities toastrUtilities = new ToastrUtilities();

                                if (updateWithdrawalTransaction)
                                {
                                    toastrUtilities.SessionPush("toast", new KeyValuePair <string, string>("success", "Successfully Updated Status"));
                                }
                                else
                                {
                                    toastrUtilities.SessionPush("toast", new KeyValuePair <string, string>("error", "Encountered Error Update Status"));
                                }
                            }
                        }
                    }
                }

                //Set Response
                AjaxResponse res = new AjaxResponse()
                {
                    Success = updateResult, DocumentId = Convert.ToInt32(DecryptedId)
                };
                return(res);
            }
        }
Exemplo n.º 2
0
        public static object InsertTransaction(NpgsqlConnection conn, string id, bool createTransferRecord = false)
        {
            MWithdrawal withdrawal = new MWithdrawal();

            withdrawal = WithdrawalUtilities.GetWithdrawal(conn, id);
            Classes.Instbtc.Models.TransactionModel transaction = new Classes.Instbtc.Models.TransactionModel();

            if (withdrawal.transaction_currency == "BTC")
            {
                #region Transaction Object BTC Wds
                transaction = new Classes.Instbtc.Models.TransactionModel()
                {
                    Psp_ID            = 2,
                    Deposit_Currency  = "USD",
                    Deposit_Amount    = (decimal)withdrawal.UsdConversion * -1,
                    Exchange_Currency = "BTC",
                    Exchange_Amount   = withdrawal.Amount * -1,
                    Created_Date      = DateTime.UtcNow,
                    Client_ID         = withdrawal.UserId,
                    Psp_Status        = "Approved",
                    Credited_Status   = "Credited",
                    type = TransactionType.WITHDRAWAL,
                    Transaction_Currency = withdrawal.transaction_currency
                };
                #endregion
            }

            else if (withdrawal.transaction_currency == "EUR")
            {
                #region Transaction Object BTC Wds
                transaction = new Classes.Instbtc.Models.TransactionModel()
                {
                    Psp_ID            = 2,
                    Deposit_Currency  = "EUR",
                    Deposit_Amount    = withdrawal.Amount * -1,
                    Exchange_Currency = "EUR",
                    Exchange_Amount   = withdrawal.Amount * -1,
                    Created_Date      = DateTime.UtcNow,
                    Client_ID         = withdrawal.UserId,
                    Psp_Status        = "Approved",
                    Credited_Status   = "Credited",
                    type = TransactionType.WITHDRAWAL,
                    Transaction_Currency = withdrawal.transaction_currency
                };
                #endregion
            }

            object res;

            if (createTransferRecord is false)
            {
                res = Classes.Instbtc.Create.Transactions.CreateTransaction(transaction);
            }
            else
            {
                res = Classes.Instbtc.Create.Transactions.CreateTransaction(transaction);

                if (res.ToString() != "Internal Error" && !string.IsNullOrEmpty(res.ToString()))
                {
                    bool isCreateTransferSuccess = TransferUtility.CreateTransfer((int)res, transaction);
                    if (isCreateTransferSuccess)
                    {
                        return(res);
                    }
                    else
                    {
                        res = "Error";
                    }
                }
            }

            return(res);
        }
Exemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string pageChecker = Request.QueryString["page"];

            if (string.IsNullOrEmpty(pageChecker))
            {
                Session.Remove("WithdrawalSearch");
            }

            using (NpgsqlConnection conn = Classes.DB.InstBTCDB("instbtc"))
            {
                NpgsqlCommand command = new NpgsqlCommand();
                string        query   = string.Empty;

                if (Request.HttpMethod == "POST")
                {
                    string status         = txtStatus.Value;
                    string clientId       = txtClientId.Value;
                    string clientEmail    = txtClientEmail.Value;
                    string clientName     = txtClientName.Value;
                    string walletId       = txtWalletId.Value;
                    string documentId     = txtWalletId.Value;
                    string createdDate    = txtCreatedDate.Value;
                    string docStatus      = txtDocStatus.Value;
                    string refferenceHash = txtHash.Value;

                    WithdrawalSearchModel searchModel = new WithdrawalSearchModel()
                    {
                        Status      = status,
                        ClientModel = new ClientModelSearch
                        {
                            Id    = clientId,
                            Email = clientEmail
                        },
                        DocumentStatus  = docStatus,
                        ClientName      = clientName,
                        WalletId        = walletId,
                        DocumentId      = documentId,
                        CreatedDate     = createdDate,
                        refference_hash = refferenceHash
                    };
                    Session["WithdrawalSearch"] = searchModel;
                }

                if (Session["WithdrawalSearch"] != null)
                {
                    WithdrawalSearchModel sessionSearchModel = (WithdrawalSearchModel)Session["WithdrawalSearch"];

                    //Get SQLCommand Parameters and Query Parameters
                    KeyValuePair <NpgsqlCommand, string> pair = getParameter(sessionSearchModel);
                    command = pair.Key;
                    query   = pair.Value;
                }

                //Get Withdrawals Datas
                List <MWithdrawal> withdrawalRequest = new List <MWithdrawal>();
                withdrawalRequest = WithdrawalUtilities.WithdrawalRequest(conn, command, query);

                #region Pagination
                Dictionary <string, int> pagerDictionary = new Dictionary <string, int>();
                string paginationString = "page";
                DocListPager.initialize(paginationString, 10);
                TotalRequest         = WithdrawalUtilities.GetWithdrawalCount(conn, command, query);
                pagerDictionary      = DocListPager.paginate(TotalRequest);
                withdrawalRequest    = WithdrawalUtilities.WithdrawalRequest(conn, command, query, pagerDictionary["offset"], pagerDictionary["limit"]);
                rowCount.InnerText   = $"{TotalRequest} Records Found";
                resultBody.InnerHtml = BuildHtmlTable(withdrawalRequest).ToString();
                #endregion

                //Get Document Statuses Selection
                OptionUtilities optionUtilities = new OptionUtilities();
                txtDocStatus.Items.Clear();
                txtDocStatus.Items.AddRange(optionUtilities.GetDocumentStatusOptions());

                //Return Values to their Fields
                ReturnFieldValues();
            }
        }