public static AjaxResponse ChangeTransactionStatus(int tid, string selectedStatus, string cid) { using (NpgsqlConnection conn = Classes.DB.InstBTCDB("instbtc")) { bool updateResult = Transactions.UpdatePspStatus(conn, tid, selectedStatus); AjaxResponse res = new AjaxResponse() { Success = updateResult, Transaction_id = tid }; if (res.Success && selectedStatus == "Approved") { //Get Transaction Informations Transactions transaction = new Transactions(); transaction = Transactions.GetTransaction(conn, tid.ToString()); //Get Client Informations ClientModel clients = new ClientModel(); clients = Clients.FindById(conn, Convert.ToInt32(cid)); //Send Email To Client var message = EmailTemplateUtilities.GetDepositTemplate(transaction); EmailTemplateUtilities.SendEmail(clients.Email, message, "Get-Bitcoin Successful Deposit"); } return(res); } }
protected void Page_Load(object sender, EventArgs e) { int clientId; this.IsUpdateSuccess = (Session["update_success"] != null) ? (bool)(Session["update_success"]) : false; if (int.TryParse(Request.QueryString["id"], out clientId) == false) { this.Redirect(); } using (NpgsqlConnection conn = Classes.DB.InstBTCDB("instbtc")) { this.Client = Clients.FindById(conn, clientId); BtcBalance = CRM.Utilities.Transactions.GetUserBtcBalance(conn, clientId.ToString()); EurBalance = CRM.Utilities.Transactions.GetUserEurBalance(conn, clientId.ToString()); CurrencyBalance = Classes.Instbtc.Utilities.Conversion.GetCurrencies(BtcBalance); if (this.Client != null) { this.ClientDocuments = Documents.GetDocuments(conn, $" AND dc.client_id = {this.Client.Id}"); this.ClientTransactions = Transactions.GetTransactions(conn, $"AND tr.client_id = { this.Client.Id}"); } NpgsqlCommand command = new NpgsqlCommand(); List <MWithdrawal> withdrawalRequest = new List <MWithdrawal>(); string query = $"SELECT w.*,e.html,e.signature FROM withdrawal w INNER JOIN clients c ON w.user_id = c.id LEFT JOIN emails e on e.wd_id = w.id WHERE w.user_id = {clientId} ORDER BY w.created_date DESC"; withdrawalRequest = WithdrawalRequest(conn, command, query); witdrawalBody.InnerHtml = BuildHtmlTable(withdrawalRequest).ToString(); } if (this.Client == null) { this.Redirect(); } Session["update_success"] = false; if (Request.HttpMethod == "POST") { Session["update_success"] = false; if (this.UpdateClient(Client)) { Session["update_success"] = true; Response.Redirect(HttpContext.Current.Request.Url.PathAndQuery); } } this.ShowDocs(); this.ShowTransactions(); }
protected void Page_Load(object sender, EventArgs e) { string username = Classes.Cookie.GetCookie("ggZurkVKwLIM+SQ2NMcfsra8/nnrhm9u5sl4TMYTE2Y", false); var roles = Utilities.AccountUtilities.getUserRoles(username); RoleUtilities roleUtilities = new RoleUtilities(); List <RolesModel> rolesModels = new List <RolesModel>(); List <string> roleLists = roles.Split(',').ToList(); if (roleLists.Find(f => f.ToLower() == "12") == null) { Response.Redirect("/dashboard.aspx"); } if (Request.HttpMethod == "POST") { #region Assign Post Variables string ClientId = Request.Form["clientId"]; string PaymentReferrence = Request.Form["pspRef"]; string PaymentStatus = Request.Form["pspStatus"]; string CreditedStatus = Request.Form["creditedStatus"]; string PspId = Request.Form["ctl00$ctl00$MainContent$LMainContent$pspId"]; string Amount = Request.Form["amount"]; string Currency = Request.Form["currency"]; string Note = Request.Form["note"]; string CardLast4 = Request.Form["cardLast4"]; string CardExpiry = Request.Form["cardExpiry"]; string CardHolderName = Request.Form["cardHolder"]; string TradingAccountId = Request.Form["PIN"]; #endregion string PIN = !string.IsNullOrEmpty(TradingAccountId) ? TradingAccountId : string.Empty; #region Get Client Info ClientModel Info = new ClientModel(); using (NpgsqlConnection conn = Classes.DB.InstBTCDB("instbtc")) { Info = Clients.FindById(conn, int.Parse(ClientId)); } #endregion if (Info != null) { #region Creating the Transaction Object Classes.Instbtc.Models.TransactionModel Transaction = new Classes.Instbtc.Models.TransactionModel { Psp_ID = decimal.Parse(PspId), Deposit_Currency = Currency, Deposit_Amount = Convert.ToDecimal(Amount), Exchange_Currency = "BTC", Exchange_Amount = Convert.ToDecimal(Classes.Instbtc.Utilities.Conversion.GetBTCAmountRestSharp(Amount, Currency)), Created_Date = DateTime.UtcNow, Client_ID = Convert.ToDecimal(ClientId), Psp_Status = PaymentStatus, Credited_Status = CreditedStatus, PaymentReference = PaymentReferrence, Notes = Note, type = Classes.Instbtc.Models.TransactionType.DEPOSIT, CardLast4 = !string.IsNullOrEmpty(CardLast4) ? CardLast4 : "", CardHolderName = !string.IsNullOrEmpty(CardHolderName) ? CardHolderName : "", Transaction_Currency = "BTC" }; #endregion #region Create The Transaction var TransactionCheck = Utilities.Transactions.CheckTransactionIfExist(Transaction.PaymentReference); object result = new object(); if (string.IsNullOrEmpty(TransactionCheck)) { result = Classes.Instbtc.Create.Transactions.CreateTransaction(Transaction); } else { toastrUtilities.SessionPush("toast", new KeyValuePair <string, string>("error", $"Cant Create Transaction, Existing Detected!")); Response.Redirect("/transaction-lists.aspx"); } #endregion if (result.ToString() != "Internal Error" || result != null) { decimal OriginalDepositTransactionAmount = decimal.Parse(Transaction.Deposit_Amount.ToString()); decimal OriginalBtcExchangeAmount = decimal.Parse(Transaction.Exchange_Amount.ToString()); EmailTemplateUtilities.SendNotificationDeposit(Info.Id.ToString(), OriginalDepositTransactionAmount.ToString(), OriginalBtcExchangeAmount.ToString(), Transaction); //if (Info.Referral.ToLower() == "lblv" || Info.Referral.ToLower() == "tradershome" || Info.Referral.ToLower() == "profitix" || Info.Referral.ToLower() == "vlom" || Info.Referral.ToLower() == "uptos" || Info.Referral.ToLower() == "fundiza" || Info.Referral.ToLower() == "kiplar" || Info.Referral.ToLower() == "investigram" || Info.Referral.ToLower() == "commercewealth") //{ // try // { // var pspList = PspUtilities.GetPspById(Transaction.Psp_ID.ToString()); // var pspName = pspList.Where(w => w.Id == int.Parse(Transaction.Psp_ID.ToString()))?.FirstOrDefault()?.Name; // pspName = pspName.Replace("USD ", "").Replace("EUR ", "").Replace("AUD ", ""); // var res = BrandsIntegration.PushToBrand(Info, Transaction, PaymentStatus, result, $"[{pspName}] " + Note, PIN, pspName); // toastrUtilities.SessionPush("toast", new KeyValuePair<string, string>("success", $"{res}")); // } // catch (Exception ex) // { // toastrUtilities.SessionPush("toast", new KeyValuePair<string, string>("error", $"{ex.Message.ToString()}")); // } //} //else //{ // decimal OriginalDepositTransactionAmount = decimal.Parse(Transaction.Deposit_Amount.ToString()); // decimal OriginalBtcExchangeAmount = decimal.Parse(Transaction.Exchange_Amount.ToString()); // EmailTemplateUtilities.SendNotificationDeposit(Info.Id.ToString(), OriginalDepositTransactionAmount.ToString(), OriginalBtcExchangeAmount.ToString(), Transaction); //} } else { toastrUtilities.SessionPush("toast", new KeyValuePair <string, string>("error", $"An Error Occured Cant Create Transaction")); } } else { //Redirect Invalid Client Id; toastrUtilities.SessionPush("toast", new KeyValuePair <string, string>("error", $"No Client With this Id: {ClientId}")); Response.Redirect("/transaction-lists.aspx"); } } OptionUtilities optionUtilities = new OptionUtilities(); pspId.Items.AddRange(optionUtilities.GetPSPOptions()); }
protected void Page_Load(object sender, EventArgs e) { if (Request.HttpMethod == "POST") { #region Get POST Variable string client_id = Request.Form["clientId"]; string from_currency = Request.Form["from_currency"]; string to_currency = Request.Form["to_currency"]; string credited_status = Request.Form["credited_status"]; string desired_amount = Request.Form["amount"]; #endregion using (NpgsqlConnection conn = Classes.DB.InstBTCDB("instbtc")) { ClientModel account = new ClientModel(); account = Clients.FindById(conn, int.Parse(client_id)); if (account == null) { toastrUtilities.SessionPush("toast", new KeyValuePair <string, string>("error", $"Invalid Client Id: {client_id}")); return; } BitcoinBalance = Clients.GetUserBtcBalance(conn, account.Id.ToString()); EuroBalance = Clients.GetUserEurBalance(conn, account.Id.ToString()); #region Validating the Convert Params, should not be the same if (from_currency == to_currency) { toastrUtilities.SessionPush("toast", new KeyValuePair <string, string>("error", $"Invalid Conversion Parameters")); return; } #endregion decimal exchange_amount = 0; string transaction_currency = string.Empty; string exchange_currency = string.Empty; if (Convert.ToDecimal(BitcoinBalance) != 0 || Convert.ToDecimal(EuroBalance) != 0) { if (from_currency == "BTC" && to_currency == "EUR") { #region Check BTC Balance is Enough to Proceed with conversion if (decimal.Parse(desired_amount) > decimal.Parse(BitcoinBalance)) { toastrUtilities.SessionPush("toast", new KeyValuePair <string, string>("error", $"Unable to perform request, Client not enough Balance.")); return; } if (decimal.Parse(desired_amount) <= 0) { toastrUtilities.SessionPush("toast", new KeyValuePair <string, string>("error", $"Unable to perform request, Client not enough Balance.")); return; } #endregion exchange_amount = decimal.Parse(Classes.Instbtc.Utilities.Conversion.KrakenBtcToEurConversion(desired_amount)); exchange_currency = "EUR"; transaction_currency = "BTC"; } else if (from_currency == "EUR" && to_currency == "BTC") { #region Check EUR Balance is Enough to Proceed with conversion if (decimal.Parse(desired_amount) > decimal.Parse(EuroBalance)) { toastrUtilities.SessionPush("toast", new KeyValuePair <string, string>("error", $"Unable to perform request, Client not enough Balance.")); return; } if (decimal.Parse(desired_amount) <= 0) { toastrUtilities.SessionPush("toast", new KeyValuePair <string, string>("error", $"Unable to perform request, Client not enough Balance.")); return; } #endregion exchange_amount = decimal.Parse(Classes.Instbtc.Utilities.Conversion.KrakenEurToBtcConversion(desired_amount)); exchange_currency = "BTC"; transaction_currency = "EUR"; } else { toastrUtilities.SessionPush("toast", new KeyValuePair <string, string>("error", $"Invalid Conversion Parameters")); return; } #region Build Conversion Request Model ConversionReqModel Model = new ConversionReqModel { client_name = $"{account.First_name} {account.Last_name}", amount = Convert.ToDecimal(Convert.ToDouble(desired_amount)), currency = transaction_currency, created_date = DateTime.UtcNow, transaction_id = null, transaction_currency = transaction_currency, credited_status = credited_status, client_id = account.Id, conversion_amount = exchange_amount, conversion_currency = exchange_currency }; #endregion string cv_id = ConversionReqUtilities.CreateConversionRequest(Model); Result = "Conversion Request Created"; if (!string.IsNullOrEmpty(cv_id)) { if (credited_status.ToLower() == "approved") { Result = Utilities.ConversionReqUtilities.ProcessConversionRequest(cv_id, credited_status); } } if (Result.Contains("Not Enough")) { toastrUtilities.SessionPush("toast", new KeyValuePair <string, string>("error", $"{Result}")); } else { toastrUtilities.SessionPush("toast", new KeyValuePair <string, string>("success", $"{Result}")); } Response.Redirect("/conversion-request.aspx"); } else { toastrUtilities.SessionPush("toast", new KeyValuePair <string, string>("error", $"Unable to perform request, Client not enough Balance.")); return; } } } }