public ActionResult Transfer(Transactionsdetail ta) { if (ModelState.IsValid) { var i = uow.Ubank.Transfer(ta); ModelState.Remove("Amount"); ModelState.Remove("To"); if (i == "completed") { uow.save(); ViewBag.headi = "Transaction"; ViewBag.transfer = "Transaction completed Sucessfully"; return View("Partialviews"); } if (i == "Failed") { ModelState.Remove("Amount"); ModelState.Remove("To"); ViewBag.headi = "Transaction"; ViewBag.transfer = "Transaction Failed"; return View("ErrorPartialViews"); } ViewBag.headi = "Transaction"; ViewBag.transfer = "Transaction Failed due to receiver account is not available (or) you not having the balance"; ModelState.Remove("Amount"); ModelState.Remove("To"); return View("ErrorPartialViews"); } return View(); }
public string Transfer(Transactionsdetail ta) { bool debitmoney = false; bool creditmoney = false; try { using (TransactionScope ts = new TransactionScope()) { var from = profile(ta.Username); var to = banklist.Where(a => a.Username.Equals(ta.Tousername)).FirstOrDefault(); if (from.AccountBalance >= ta.Balance && to != null) { BankAccount bafrom = from; bafrom.AccountBalance = bafrom.AccountBalance - ta.Balance; BankAccount bato = to; bato.AccountBalance = bato.AccountBalance + ta.Balance; Transactionsdetail tddebit = new Transactionsdetail(); tddebit.Username = from.Username; tddebit.Tousername = ta.Tousername; tddebit.datetimes = DateTime.Now; tddebit.debit = ta.Balance; tddebit.credit = null; tddebit.Balance = bafrom.AccountBalance; tddebit.Types = "Transaction"; translist.Add(tddebit); Transactionsdetail tdcredit = new Transactionsdetail(); tdcredit.Username = ta.Tousername; tdcredit.Tousername = from.Username; tdcredit.datetimes = DateTime.Now; tdcredit.debit = null; tdcredit.credit = ta.Balance; tdcredit.Types = "Transaction"; tdcredit.Balance = bato.AccountBalance; translist.Add(tdcredit); debitmoney = true; creditmoney = true; if (debitmoney && creditmoney) { ts.Complete(); return "completed"; } } } } catch { return "Failed"; } return "no"; }
public ActionResult Deposite(Transactionsdetail ta) { if (ModelState.IsValid) { uow.Ubank.Deposite(ta); uow.save(); ViewBag.headi = "Deposite"; ViewBag.transfer = "Deposited sucessfully"; return View("Partialviews"); } return View(); }
public void Deposite(Transactionsdetail ta) { var userdeposite = profile(ta.Username); BankAccount ba = userdeposite; ba.AccountBalance = ba.AccountBalance + ta.Balance; Transactionsdetail td = new Transactionsdetail(); td.Username = ta.Username; td.Types = "Deposit"; td.Tousername = ta.Tousername; td.credit = ta.Balance; td.datetimes = DateTime.Now; td.Balance = ba.AccountBalance; translist.Add(td); }
public ActionResult Withdraw(Transactionsdetail ta) { if (ModelState.IsValid) { var i = uow.Ubank.Withdraw(ta); if (i == "Completed") { uow.save(); ViewBag.headi = "Withdraw"; ViewBag.transfer = "Withdraw sucessfully"; return View("Partialviews"); } ViewBag.headi = "Withdraw"; ViewBag.transfer = "Withdraw Failed Check your account name and your balance"; return View("ErrorPartialViews"); } return View(); }
public string Withdraw(Transactionsdetail ta) { var userwithdraw = profile(ta.Username); if (userwithdraw.AccountBalance >= ta.Balance) { BankAccount ba = userwithdraw; ba.AccountBalance = ba.AccountBalance - ta.Balance; Transactionsdetail td = new Transactionsdetail(); td.Username = ta.Username; td.Tousername = ta.Tousername; td.Types = "Withdraw"; td.debit = ta.Balance; td.Balance = ba.AccountBalance; td.datetimes = DateTime.Now; context.transdetails.Add(td); return "Completed"; } return "Failed"; }
public HomeControllerTest() { ba1 = new BankAccount { id = 1, Username = "******", password = "******", AccountBalance = 25000 }; ba2 = new BankAccount { id = 2, Username = "******", password = "******", AccountBalance = 20000 }; td1 = new Transactionsdetail {id = 1,Username = "******",Tousername = "******",datetimes = DateTime.Now,debit = null,credit = 25000, Types = "Deposit",Balance = 25000 }; td2 = new Transactionsdetail { id = 2, Username = "******", Tousername = "******", datetimes = DateTime.Now,debit = null,credit = 20000, Types = "Deposit", Balance = 20000 }; td3 = new Transactionsdetail {id = 3,Username = "******",Tousername = "******",datetimes = DateTime.Now,debit = 1000,credit = null, Types = "Withdraw",Balance = 20000}; banklist = new List<BankAccount> { ba1, ba2 }; translist = new List<Transactionsdetail> { td1, td2,td3 }; dummyrepo = new BankDummyRepository(translist, banklist); uow = new unitofworkclass(dummyrepo); controller = new HomeController(uow); }
public void Transfer_to_not_having_account() { Transactionsdetail t = new Transactionsdetail { Username = "******", Tousername = "******", Balance = 1500 }; var result = controller.Transfer(t) as ViewResult; Assert.AreEqual("Transaction Failed due to receiver account is not available (or) you not having the balance", result.ViewBag.transfer); }
public void Transfer() { Transactionsdetail t = new Transactionsdetail { Username = "******",Tousername="******", Balance = 1500 }; var result = controller.Transfer(t) as ViewResult; Assert.AreEqual("Transaction completed Sucessfully", result.ViewBag.transfer); }
public void Withdraw_money_more_than_your_account() { Transactionsdetail t = new Transactionsdetail { Username = "******", Balance = 1500000 }; var result = controller.Withdraw(t) as ViewResult; Assert.AreEqual("Withdraw Failed Check your account name and your balance", result.ViewBag.transfer); }
public void Withdraw() { Transactionsdetail t = new Transactionsdetail { Username = "******", Balance = 1500 }; var result = controller.Withdraw(t) as ViewResult; Assert.AreEqual("Withdraw sucessfully", result.ViewBag.transfer); }
public void Deposite() { Transactionsdetail t = new Transactionsdetail { Username = "******", Balance = 500 }; var result = controller.Deposite(t) as ViewResult; Assert.AreEqual("Deposited sucessfully", result.ViewBag.transfer); }