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 deposit(dwacc value) { TransactionMsg ob = new TransactionMsg(); ob.Message = "Success"; return(ob); }
public string withdraw([FromBody] dwacc value) { string data = JsonConvert.SerializeObject(value); StringContent content = new StringContent(data, Encoding.UTF8, "application/json"); HttpResponseMessage response = client.PostAsync(client.BaseAddress + "/Transaction/withdraw/", content).Result; if (response.IsSuccessStatusCode) { string data1 = response.Content.ReadAsStringAsync().Result; if (data1 == "Transaction Success") { if (value.AccountId % 2 == 0) { var sa = savingsAccounts.Find(a => a.SAId == value.AccountId); sa.SBal = sa.SBal - value.Balance; return("Withdrawn Successfully.New Balance Rs." + sa.SBal + ".00"); } var ca = currentAccounts.Find(a => a.CAId == value.AccountId); ca.CBal = ca.CBal - value.Balance; return("Withdrawn Successfully.New Balance Rs." + ca.CBal + ".00"); } return("Withdrawn 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 TransactionMsg withdraw(dwacc value) { TransactionMsg ob = new TransactionMsg(); string data = JsonConvert.SerializeObject(value); 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 string deposit([FromBody] dwacc value) { GetListRep ob = new GetListRep(); var customeraccounts = ob.GetCustomeraccountsList(); string data = JsonConvert.SerializeObject(value); StringContent content = new StringContent(data, Encoding.UTF8, "application/json"); HttpResponseMessage response = client.PostAsync(client.BaseAddress + "/Transaction/deposit/", content).Result; if (response.IsSuccessStatusCode) { _log4net.Info(" Amount Deposited "); string data1 = response.Content.ReadAsStringAsync().Result; if (data1 == "Success") { if (value.AccountId % 2 == 0) { var sa = savingsAccounts.Find(a => a.SAId == value.AccountId); sa.SBal = sa.SBal + value.Balance; return("Deposited Successfully.New Account Rs." + sa.SBal + ".00"); } var ca = currentAccounts.Find(a => a.CAId == value.AccountId); ca.CBal = ca.CBal + value.Balance; return("Deposited Successfully.New Account Rs." + ca.CBal + ".00"); } return("Deposition Failed"); } return("Link Failure"); }
public AccountMsg deposit(dwacc value) { string data = JsonConvert.SerializeObject(value); StringContent content = new StringContent(data, Encoding.UTF8, "application/json"); HttpResponseMessage response = client.PostAsync(client.BaseAddress + "/Transaction/deposit/", content).Result; if (response.IsSuccessStatusCode) { string data1 = response.Content.ReadAsStringAsync().Result; Ts s1 = JsonConvert.DeserializeObject <Ts>(data1); if (s1.Message == "Success") { if (value.AccountId % 2 == 0) { var sa = savingsAccounts.Find(a => a.savingsAccountId == value.AccountId); sa.savingsAccountbalance = sa.savingsAccountbalance + value.Balance; AccountMsg sob = new AccountMsg { accountId = value.AccountId, AccType = "Deposited Correctly", AccBal = sa.savingsAccountbalance }; return(sob); } var ca = currentAccounts.Find(a => a.CAId == value.AccountId); ca.CBal = ca.CBal + value.Balance; AccountMsg cob = new AccountMsg { accountId = value.AccountId, AccType = "Deposited Correctly", AccBal = ca.CBal }; return(cob); } /* if (value.AccountId % 2 == 0) * { * var sad = savingsAccounts.Find(a => a.savingsAccountId == value.AccountId); * sad.savingsAccountbalance = sad.savingsAccountbalance + value.Balance; * AccountMsg sobd = new AccountMsg * { * accountId = value.AccountId, * AccType = "Deposited Correctly", * AccBal = sad.savingsAccountbalance * }; * return sobd; * } * var cad = currentAccounts.Find(a => a.CAId == value.AccountId); * cad.CBal = cad.CBal + value.Balance; * AccountMsg cobd = new AccountMsg * { * accountId = value.AccountId, * AccType = "Deposited Correctly", * AccBal = cad.CBal * }; * return cobd;*/ } return(null); }
public void withdraw_InsufficeintBalace_ReturnsBadRequest() { var mock = new Mock <TransactionRep>(); TransactionController t1 = new TransactionController(mock.Object); dwacc d1 = new dwacc(); var data = t1.withdraw(d1); var res = data as BadRequestResult; Assert.AreEqual(400, res.StatusCode); }
public void deposit_CorrectAmount_ReturnsOKResult() { var mock = new Mock <TransactionRep>(); TransactionController t1 = new TransactionController(mock.Object); dwacc d1 = new dwacc { AccountId = 1, Balance = 2000 }; var data = t1.deposit(d1); var res = data as OkObjectResult; Assert.AreEqual(200, res.StatusCode); }
public void deposit_AmountNotZero_ReturnsNotNullValue() { var mock = new Mock <TransactionRep>(); TransactionController t1 = new TransactionController(mock.Object); dwacc d1 = new dwacc { AccountId = 1, Balance = 2000 }; var data = t1.deposit(d1); // var res = data as OkObjectResult; Assert.IsNotNull(data); }
public string withdraw([FromBody] dwacc value) { string data = JsonConvert.SerializeObject(value); 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 == "Warning") { return("Warning"); } return("No Warning"); } return("Link Failure"); }
public ruleStatus evaluateMinBal(dwacc value) { AccountMsg ob = new AccountMsg(); ruleStatus ob1 = new ruleStatus(); HttpResponseMessage response = client.GetAsync(client.BaseAddress + "/Account/getAccount/" + value.AccountId).Result; if (response.IsSuccessStatusCode) { string data = response.Content.ReadAsStringAsync().Result; ob = JsonConvert.DeserializeObject <AccountMsg>(data); ob.AccBal = ob.AccBal - value.Balance; if (ob.AccBal < 500) { ob1.message = "Warning"; } else { ob1.message = "No Warning"; } } return(ob1); }
public string deposit(dwacc value) { throw new NotImplementedException(); }
public string withdraw(dwacc value) { throw new NotImplementedException(); }
public string deposit([FromBody] dwacc value) { return("Success"); }
public object withdraw(dwacc d1) { throw new NotImplementedException(); }
public object deposit(dwacc d1) { throw new NotImplementedException(); }
public AccountMsg withdraw(dwacc value) { string data = JsonConvert.SerializeObject(value); StringContent content = new StringContent(data, Encoding.UTF8, "application/json"); HttpResponseMessage response = client.PostAsync(client.BaseAddress + "/Transaction/withdraw/", content).Result; if (response.IsSuccessStatusCode) { string data1 = response.Content.ReadAsStringAsync().Result; Ts s1 = JsonConvert.DeserializeObject <Ts>(data1); AccountMsg amsg = new AccountMsg(); if (s1.Message == "No Warning") { if (value.AccountId % 2 == 0) { var sa = savingsAccounts.Find(a => a.savingsAccountId == value.AccountId); sa.savingsAccountbalance = sa.savingsAccountbalance - value.Balance; if (sa.savingsAccountbalance >= 0) { amsg.accountId = value.AccountId; amsg.AccType = "Withdrawn Successfully"; amsg.AccBal = sa.savingsAccountbalance; return(amsg); } else { sa.savingsAccountbalance = sa.savingsAccountbalance + value.Balance; amsg.accountId = value.AccountId; amsg.AccType = "Insufficient Fund"; amsg.AccBal = sa.savingsAccountbalance; return(amsg); } } var car = currentAccounts.Find(a => a.CAId == value.AccountId); car.CBal = car.CBal - value.Balance; if (car.CBal >= 0) { amsg.accountId = value.AccountId; amsg.AccType = "Withdrawn Successfully"; amsg.AccBal = car.CBal; return(amsg); } else { car.CBal = car.CBal + value.Balance; amsg.accountId = value.AccountId; amsg.AccType = "Insufficient Fund"; amsg.AccBal = car.CBal; return(amsg); } } if (value.AccountId % 2 == 0) { var sa = savingsAccounts.Find(a => a.savingsAccountId == value.AccountId); sa.savingsAccountbalance = sa.savingsAccountbalance - value.Balance; if (sa.savingsAccountbalance >= 0) { amsg.accountId = value.AccountId; amsg.AccType = "Withdrawn Successfully.Service charge applicable at the end of month"; amsg.AccBal = sa.savingsAccountbalance; return(amsg); } else { sa.savingsAccountbalance = sa.savingsAccountbalance + value.Balance; amsg.accountId = value.AccountId; amsg.AccType = "Insufficient Fund"; amsg.AccBal = sa.savingsAccountbalance; return(amsg); } } var ca = currentAccounts.Find(a => a.CAId == value.AccountId); ca.CBal = ca.CBal - value.Balance; if (ca.CBal >= 0) { amsg.accountId = value.AccountId; amsg.AccType = "Withdrawn Successfully.Service Charge Applicable at the end of month"; amsg.AccBal = ca.CBal; return(amsg); } else { ca.CBal = ca.CBal + value.Balance; amsg.accountId = value.AccountId; amsg.AccType = "Insufficient Fund"; amsg.AccBal = ca.CBal; return(amsg); } } return(null); }
public string deposit([FromBody] dwacc value) { _log4net.Info("Deposited Money"); return("Success"); }
public string withdraw([FromBody] dwacc value) { GetListRep ob = new GetListRep(); var customeraccounts = ob.GetCustomeraccountsList(); string data = JsonConvert.SerializeObject(value); StringContent content = new StringContent(data, Encoding.UTF8, "application/json"); HttpResponseMessage response = client.PostAsync(client.BaseAddress + "/Transaction/withdraw/", content).Result; if (response.IsSuccessStatusCode) { _log4net.Info("Amount Withdrawn"); string data1 = response.Content.ReadAsStringAsync().Result; if (data1 == "No Warning") { if (value.AccountId % 2 == 0) { var sa = savingsAccounts.Find(a => a.SAId == value.AccountId); sa.SBal = sa.SBal - value.Balance; if (sa.SBal >= 0) { return("Withdrawn Successfully.New Balance Rs." + sa.SBal + ".00"); } else { sa.SBal = sa.SBal + value.Balance; return("Insufficient Fund"); } } var car = currentAccounts.Find(a => a.CAId == value.AccountId); car.CBal = car.CBal - value.Balance; if (car.CBal >= 0) { return("Withdrawn Successfully.New Balance Rs." + car.CBal + ".00"); } else { car.CBal = car.CBal + value.Balance; return("Insufficient Fund"); } } if (value.AccountId % 2 == 0) { var sa = savingsAccounts.Find(a => a.SAId == value.AccountId); sa.SBal = sa.SBal - value.Balance; if (sa.SBal >= 0) { return("Withdrawn Successfully.New Balance Rs." + sa.SBal + ".00 but service charge will be deducted at the end of month"); } else { sa.SBal = sa.SBal + value.Balance; return("Insufficient Fund"); } } var ca = currentAccounts.Find(a => a.CAId == value.AccountId); ca.CBal = ca.CBal - value.Balance; if (ca.CBal >= 0) { return("Withdrawn Successfully.New Balance Rs." + ca.CBal + ".00 but service charge will be deducted at the end of month"); } else { ca.CBal = ca.CBal + value.Balance; return("Insufficient Fund"); } } return("Link Failure"); }