public async Task <TransactionStatus> deposit([FromBody] dynamic model /*int AccountId, int amount*/) { HttpClient client = obj.AccountDetails(); HttpResponseMessage response = client.GetAsync("api/Account/getAccount/?AccountId=" + model.AccountId).Result; var result = response.Content.ReadAsStringAsync().Result; Account acc = JsonConvert.DeserializeObject <Account>(result); HttpResponseMessage response1 = client.PostAsJsonAsync("api/Account/deposit", new { AccountID = Convert.ToInt32(model.AccountId), Amount = Convert.ToInt32(model.amount) }).Result; var result1 = response1.Content.ReadAsStringAsync().Result; TransactionStatus st = JsonConvert.DeserializeObject <TransactionStatus>(result1); cnt = cnt + 256; TransactionHistory history = new TransactionHistory() { TransactionId = cnt, AccountId = Convert.ToInt32(model.AccountId), message = st.message, source_balance = st.source_balance, destination_balance = st.destination_balance, DateOfTransaction = DateTime.Now, CustomerId = acc.CustomerId }; _provider.AddToTransactionHistory(history); return(st); }
/// <summary> /// From Here we are calling Account api to get Account object /// </summary> /// <param name="AccountId"></param> /// <returns></returns> public Account GetAccount(int AccountId) { Account account = new Account(); try { Client obj = new Client(); HttpClient client = obj.AccountDetails(); HttpResponseMessage response = client.GetAsync("api/Account/getAccount/" + AccountId).Result; if (response.StatusCode == System.Net.HttpStatusCode.InternalServerError) { throw new ArgumentNullException("error in calling Account API to get Account"); } var result = response.Content.ReadAsStringAsync().Result; account = JsonConvert.DeserializeObject <Account>(result); } catch (ArgumentNullException e) { _log4net.Error(e.Message); throw e; } catch (Exception e) { _log4net.Error("Exception occured while getting Account details for account id: " + AccountId); throw e; } return(account); }
/// <summary> /// Here we are communicating with Account api to actually deposit to a given AccountId /// </summary> /// <param name="AccountId"></param> /// <param name="amount"></param> /// <returns></returns> public TransactionStatus Deposit(int AccountId, int amount) { TransactionStatus status = new TransactionStatus(); try { Client obj = new Client(); HttpClient client = obj.AccountDetails(); HttpResponseMessage response = client.PostAsJsonAsync("api/Account/deposit", new { AccountId = AccountId, amount = amount }).Result; if (response.StatusCode == System.Net.HttpStatusCode.InternalServerError) { throw new ArgumentNullException("Error in calling Account API to deposit money"); } var result = response.Content.ReadAsStringAsync().Result; status = JsonConvert.DeserializeObject <TransactionStatus>(result); } catch (ArgumentNullException e) { _log4net.Error(e.Message); throw e; } catch (Exception e) { _log4net.Error("Not able to deposit in account with account id " + AccountId + " and amount " + amount); throw e; } return(status); }
public async Task <IActionResult> deposit([FromBody] dynamic model /*int AccountId, int amount*/) { if (Convert.ToInt32(model.AccountId) == 0 || Convert.ToInt32(model.amount) == 0) { _log4net.Info("Either AccountId or amount is invalid"); return(NotFound(new TransactionStatus() { message = "Withdraw Not Allowed" })); } HttpClient client = obj.AccountDetails(); _log4net.Info("getAccount Api called"); HttpResponseMessage response = client.GetAsync("api/Account/getAccount/?AccountId=" + model.AccountId).Result; var result = response.Content.ReadAsStringAsync().Result; Account acc = JsonConvert.DeserializeObject <Account>(result); _log4net.Info("deposit Api called"); HttpResponseMessage response1 = client.PostAsJsonAsync("api/Account/deposit", new { AccountId = Convert.ToInt32(model.AccountId), amount = Convert.ToInt32(model.amount) }).Result; var result1 = response1.Content.ReadAsStringAsync().Result; TransactionStatus st = JsonConvert.DeserializeObject <TransactionStatus>(result1); cnt = cnt + 256; TransactionHistory history = new TransactionHistory() { TransactionId = cnt, AccountId = Convert.ToInt32(model.AccountId), message = st.message, source_balance = st.source_balance, destination_balance = st.destination_balance, DateOfTransaction = DateTime.Now, CustomerId = acc.CustomerId }; _provider.AddToTransactionHistory(history); _log4net.Info("Valid AccountId and amount"); return(Ok(st)); }
/// <summary> /// Here we are communicating with Account api to actually /// withdraw from a given AccountId /// </summary> /// <param name="AccountId"></param> /// <param name="amount"></param> /// <returns></returns> public TransactionStatus Withdraw(int AccountId, int amount) { TransactionStatus status = new TransactionStatus(); try { Client obj = new Client(); HttpClient client = obj.AccountDetails(); HttpResponseMessage response = client.PostAsJsonAsync("api/Account/withdraw", new { AccountId = AccountId, amount = amount }).Result; var result = response.Content.ReadAsStringAsync().Result; status = JsonConvert.DeserializeObject <TransactionStatus>(result); } catch (Exception e) { _log4net.Error("Not able to withdraw from account with account id " + AccountId + " and amount " + amount); throw e; } return(status); }
/// <summary> /// From Here we are calling Account api to get Account object /// </summary> /// <param name="AccountId"></param> /// <returns></returns> public Account GetAccount(int AccountId) { Account account = new Account(); try { Client obj = new Client(); HttpClient client = obj.AccountDetails(); HttpResponseMessage response = client.GetAsync("api/Account/getAccount/" + AccountId).Result; var result = response.Content.ReadAsStringAsync().Result; account = JsonConvert.DeserializeObject <Account>(result); } catch (Exception e) { _log4net.Error("Exception occured while getting Account details for account id: " + AccountId); throw e; } return(account); }
/// <summary> /// Form Load /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Account_Load(object sender, EventArgs e) { //Account Details string AccountDetails = client.AccountDetails(Token); //AccountDetails is an array if (AccountDetails.Contains("|")) { string[] AccountInfo = AccountDetails.Split('|'); Console.WriteLine("Account Details: " + AccountDetails); this.memberShipID.Text += AccountInfo[0]; this.memberName.Text += AccountInfo[1]; this.memberHWID.Text += AccountInfo[2]; this.memberDiscord.Text += AccountInfo[3]; if (AccountInfo.Length > 5) { this.memberProducts.Text += AccountInfo[5].Replace("1", "GTA5").Replace("2", " CS:GO"); } else { this.memberProducts.Text += "-"; } if (AccountInfo.Length > 8) { this.Licenses += AccountInfo[8]; } else { this.Licenses += "-"; } } else { this.memberShipID.Text = "A Error has occured"; this.memberHWID.Text = "A Error has occured"; this.memberName.Text = "A Error has occured"; this.memberLicenses.Text = "A Error has occured"; this.memberProducts.Text = "A Error has occured"; this.memberDiscord.Text = "A Error has occured"; } //Products string owned = client.Products(Token).Replace("Packages=", ""); if (owned != "" && owned != "API Quota Reached") { if (!owned.Contains("|")) { productInfoLabel.Text = ""; string[] product_details = owned.Split('-'); int Id = Convert.ToInt32(product_details[0]); //UID string Name = product_details[1]; //Product Name string File = product_details[2]; //Product Media int Status = Convert.ToInt32(product_details[3]); //Product Status int Version = Convert.ToInt32(product_details[4]); productInfoLabel.Text += "Product Information - " + Name + Environment.NewLine; productInfoLabel.Text += "ID: " + Id + Environment.NewLine; productInfoLabel.Text += "Version: v" + Version + Environment.NewLine; productInfoLabel.Text += "Name: " + Name + Environment.NewLine; productInfoLabel.Text += "File: " + File + Environment.NewLine; productInfoLabel.Text += "Status: " + Status + Environment.NewLine + Environment.NewLine; } else { productInfoLabel.Text = ""; foreach (string product in owned.Split('|')) { string[] product_details = product.Split('-'); int Id = Convert.ToInt32(product_details[0]); //UID string Name = product_details[1]; //Product Name string File = product_details[2]; //Product Media int Status = Convert.ToInt32(product_details[3]); //Product Status int Version = Convert.ToInt32(product_details[4]); productInfoLabel.Text += "Product Information - " + Name + Environment.NewLine; productInfoLabel.Text += "ID: " + Id + Environment.NewLine; productInfoLabel.Text += "Version: v" + Version + Environment.NewLine; productInfoLabel.Text += "Name: " + Name + Environment.NewLine; productInfoLabel.Text += "File: " + File + Environment.NewLine; productInfoLabel.Text += "Status: " + Status + Environment.NewLine + Environment.NewLine; } } } else if (owned == "API Quota Reached") { MessageBox.Show("Your IP has been temporarily banned as a security percaution, try again in a few minutes!"); } else { Console.WriteLine("You do not own any cheats, please activate some!"); } }