public string transfer([FromBody] transfers value) { _log4net.Info("Transfer"); dwacc sa = new dwacc { AccountId = value.source_accid, Balance = value.amount }; string data = JsonConvert.SerializeObject(sa); StringContent content = new StringContent(data, Encoding.UTF8, "application/json"); HttpResponseMessage response = client.PostAsync(client.BaseAddress + "/Rules/evaluateMinBal/", content).Result; if (response.IsSuccessStatusCode) { string data1 = response.Content.ReadAsStringAsync().Result; if (data1 == "Allowed") { return("Transaction Success"); } return("Transaction Failed"); } return("Link Failure"); }
public TransactionMsg transfer(transfers value) { dwacc ob4 = new dwacc { AccountId = value.source_accid, Balance = value.amount }; TransactionMsg ob = new TransactionMsg(); string data = JsonConvert.SerializeObject(ob4); StringContent content = new StringContent(data, Encoding.UTF8, "application/json"); HttpResponseMessage response = client.PostAsync(client.BaseAddress + "/Rules/evaluateMinBal/", content).Result; if (response.IsSuccessStatusCode) { string data1 = response.Content.ReadAsStringAsync().Result; ruleStatus s1 = JsonConvert.DeserializeObject <ruleStatus>(data1); if (s1.message == "Warning") { ob.Message = "Warning"; return(ob); } ob.Message = "No Warning"; return(ob); } return(null); }
public void transfer_InsufficeintBalace_ReturnsBadRequest() { var mock = new Mock <TransactionRep>(); TransactionController t1 = new TransactionController(mock.Object); transfers d1 = new transfers { source_accid = 1, destination_accid = 2, amount = 1000 }; var data = t1.transfer(d1); var res = data as BadRequestResult; Assert.AreEqual(400, res.StatusCode); }
public IActionResult transfer([FromBody] transfers value) { try { var ob = transactionRepository.transfer(value); if (ob == null) { return(NotFound()); } return(Ok(ob)); } catch (Exception) { return(BadRequest()); } }
public IActionResult transfer([FromBody] transfers value) { _log4net.Info("Amount Transferred"); try { var ob = accountRepository.transfer(value); if (ob == null) { return(NotFound("Either Zero Balance or Link Failure")); } return(Ok(ob)); } catch (Exception) { return(BadRequest()); } }
public string transfer([FromBody] transfers value) { double sb = 0.0, db = 0.0; string data = JsonConvert.SerializeObject(value); StringContent content = new StringContent(data, Encoding.UTF8, "application/json"); HttpResponseMessage response = client.PostAsync(client.BaseAddress + "/Transaction/transfer/", content).Result; if (response.IsSuccessStatusCode) { _log4net.Info("Amount Transferred"); string data1 = response.Content.ReadAsStringAsync().Result; if (data1 == "Transaction Success") { if (value.source_accid % 2 == 0) { var sas = savingsAccounts.Find(a => a.SAId == value.source_accid); sas.SBal = sas.SBal - value.amount; sb = sas.SBal; } else { var cas = currentAccounts.Find(a => a.CAId == value.source_accid); cas.CBal = cas.CBal - value.amount; sb = cas.CBal; } if (value.destination_accid % 2 == 0) { var sa = savingsAccounts.Find(a => a.SAId == value.destination_accid); sa.SBal = sa.SBal + value.amount; db = sa.SBal; } else { var ca = currentAccounts.Find(a => a.CAId == value.destination_accid); ca.CBal = ca.CBal + value.amount; db = ca.CBal; } return("Sender Account Balance Rs." + sb + ".00\n" + "Receiver Account Balance Rs." + db + ".00"); } return("Transfer Failure.Check minimum balance in account"); } return("Link Failure"); }
public IActionResult transfer([FromBody] transfers value) { _log4net.Info("Transfer checking inititaed"); try { var ob = transactionRepository.transfer(value); if (ob == null) { _log4net.Info("Transfer not possible from Rules Microservice"); return(NotFound()); } _log4net.Info("Transfer possible from Rules Microservice"); return(Ok(ob)); } catch (Exception) { return(BadRequest()); } }
public IActionResult transfer(transfers accountBalance) { string data = JsonConvert.SerializeObject(accountBalance); StringContent content = new StringContent(data, Encoding.UTF8, "application/json"); HttpResponseMessage response = client.PostAsync(client.BaseAddress + "/Account/transfer/", content).Result; if (response.IsSuccessStatusCode) { string data1 = response.Content.ReadAsStringAsync().Result; transactionmsg ob4 = JsonConvert.DeserializeObject <transactionmsg>(data1); if (ob4 != null) { return(RedirectToAction("TransferStatus", "Customer", ob4)); } else { return(RedirectToAction("Error")); } } return(BadRequest()); }
public string transfer(transfers value) { throw new NotImplementedException(); }
public transactionStatusDetails transfer(transfers value) { double sb = 0.0, db = 0.0; string data = JsonConvert.SerializeObject(value); StringContent content = new StringContent(data, Encoding.UTF8, "application/json"); HttpResponseMessage response = client.PostAsync(client.BaseAddress + "/Transaction/transfer/", content).Result; if (response.IsSuccessStatusCode) { string data1 = response.Content.ReadAsStringAsync().Result; Ts s1 = JsonConvert.DeserializeObject <Ts>(data1); transactionStatusDetails ob = new transactionStatusDetails(); if (s1.Message == "No Warning") { if (value.senderAccountId % 2 == 0) { var sas = savingsAccounts.Find(a => a.savingsAccountId == value.senderAccountId); sas.savingsAccountbalance = sas.savingsAccountbalance - value.amount; if (sas.savingsAccountbalance >= 0) { sb = sas.savingsAccountbalance; } else { sas.savingsAccountbalance = sas.savingsAccountbalance + value.amount; return(null); } } else { var cas = currentAccounts.Find(a => a.currentAccountId == value.senderAccountId); cas.currentAccountBalance = cas.currentAccountBalance - value.amount; if (cas.currentAccountBalance >= 0) { sb = cas.currentAccountBalance; } else { cas.currentAccountBalance = cas.currentAccountBalance + value.amount; return(null); } } if (value.receiverAccountId % 2 == 0) { var sa = savingsAccounts.Find(a => a.savingsAccountId == value.receiverAccountId); sa.savingsAccountbalance = sa.savingsAccountbalance + value.amount; db = sa.savingsAccountbalance; } else { var ca = currentAccounts.Find(a => a.currentAccountId == value.receiverAccountId); ca.currentAccountBalance = ca.currentAccountBalance + value.amount; db = ca.currentAccountBalance; } ob.senderBalance = sb; ob.receiverBalance = db; ob.transferStatus = "Transfer Successfull"; return(ob); } else { if (value.senderAccountId % 2 == 0) { var sas = savingsAccounts.Find(a => a.savingsAccountId == value.senderAccountId); sas.savingsAccountbalance = sas.savingsAccountbalance - value.amount; if (sas.savingsAccountbalance >= 0) { sb = sas.savingsAccountbalance; } else { sas.savingsAccountbalance = sas.savingsAccountbalance + value.amount; return(null); } } else { var cas = currentAccounts.Find(a => a.currentAccountId == value.senderAccountId); cas.currentAccountBalance = cas.currentAccountBalance - value.amount; if (cas.currentAccountBalance >= 0) { sb = cas.currentAccountBalance; } else { cas.currentAccountBalance = cas.currentAccountBalance + value.amount; return(null); } } if (value.receiverAccountId % 2 == 0) { var sa = savingsAccounts.Find(a => a.savingsAccountId == value.receiverAccountId); sa.savingsAccountbalance = sa.savingsAccountbalance + value.amount; db = sa.savingsAccountbalance; } else { var ca = currentAccounts.Find(a => a.currentAccountId == value.receiverAccountId); ca.currentAccountBalance = ca.currentAccountBalance + value.amount; db = ca.currentAccountBalance; } ob.senderBalance = sb; ob.receiverBalance = db; ob.transferStatus = "Transfer Successfull.But Service Charge is applicable in sender account"; return(ob); //return "Sender Account Balance Rs." + sb + ".00\n" + "Receiver Account Balance Rs." + db + ".00\n but service charge will be deducted at the end of month from your account"; } } return(null); }
public string transfer([FromBody] transfers value) { GetListRep ob = new GetListRep(); var customeraccounts = ob.GetCustomeraccountsList(); // var currentAccounts = ob.GetCurrentAccountsList(); // var savingsAccounts = ob.GetSavingsAccountsList(); double sb = 0.0, db = 0.0; string data = JsonConvert.SerializeObject(value); StringContent content = new StringContent(data, Encoding.UTF8, "application/json"); HttpResponseMessage response = client.PostAsync(client.BaseAddress + "/Transaction/transfer/", content).Result; if (response.IsSuccessStatusCode) { _log4net.Info("Amount Transferred"); string data1 = response.Content.ReadAsStringAsync().Result; if (data1 == "No Warning") { if (value.source_accid % 2 == 0) { var sas = savingsAccounts.Find(a => a.SAId == value.source_accid); sas.SBal = sas.SBal - value.amount; if (sas.SBal >= 0) { sb = sas.SBal; } else { sas.SBal = sas.SBal + value.amount; return("Insufficient Fund"); } } else { var cas = currentAccounts.Find(a => a.CAId == value.source_accid); cas.CBal = cas.CBal - value.amount; if (cas.CBal >= 0) { sb = cas.CBal; } else { cas.CBal = cas.CBal + value.amount; return("Insufficient Fund"); } } if (value.destination_accid % 2 == 0) { var sa = savingsAccounts.Find(a => a.SAId == value.destination_accid); sa.SBal = sa.SBal + value.amount; db = sa.SBal; } else { var ca = currentAccounts.Find(a => a.CAId == value.destination_accid); ca.CBal = ca.CBal + value.amount; db = ca.CBal; } return("Sender Account Balance Rs." + sb + ".00\n" + "Receiver Account Balance Rs." + db + ".00"); } else { if (value.source_accid % 2 == 0) { var sas = savingsAccounts.Find(a => a.SAId == value.source_accid); sas.SBal = sas.SBal - value.amount; if (sas.SBal >= 0) { sb = sas.SBal; } else { sas.SBal = sas.SBal + value.amount; return("Insufficient Fund"); } } else { var cas = currentAccounts.Find(a => a.CAId == value.source_accid); cas.CBal = cas.CBal - value.amount; if (cas.CBal >= 0) { sb = cas.CBal; } else { cas.CBal = cas.CBal + value.amount; return("Insufficient Fund"); } } if (value.destination_accid % 2 == 0) { var sa = savingsAccounts.Find(a => a.SAId == value.destination_accid); sa.SBal = sa.SBal + value.amount; db = sa.SBal; } else { var ca = currentAccounts.Find(a => a.CAId == value.destination_accid); ca.CBal = ca.CBal + value.amount; db = ca.CBal; } return("Sender Account Balance Rs." + sb + ".00\n" + "Receiver Account Balance Rs." + db + ".00\n but service charge will be deducted at the end of month from your account"); } } return("Link Failure"); }