public ActionResult Index(CompoundInterest c) { if (ModelState.IsValid) { var result = c.CompoundInterestCalculator(); TempData["balance"] = result.ToString(); return(RedirectToAction("Index", new { p = c.Principal, i = c.InterestRate, t = c.TimesCompounded, y = c.Years })); } return(View(c)); }
public void P1000T12I5Y10Results1647dot01() { CompoundInterest ci = new CompoundInterest() { Principal = 1000, TimesCompounded = 12, InterestRate = 5, Years = 10 }; var expected = 1647.01; var actual = Math.Round(ci.CompoundInterestCalculator(), 2); Assert.Equal(expected, actual); }
public IActionResult Index([FromQuery] string p, [FromQuery] string i, [FromQuery] string t, [FromQuery] string y, [FromQuery] string x) { CompoundInterest c = new CompoundInterest(); if (p != null && i != null && t != null && y != null ) { c.Principal = Convert.ToDouble(p); c.InterestRate = Convert.ToDouble(i); c.TimesCompounded = Convert.ToInt32(t); c.Years = Convert.ToInt32(y); } else { c.Principal = 1000; c.InterestRate = 5; c.TimesCompounded = 12; c.Years = 10; } if (string.IsNullOrEmpty(_config["REGION"])) { ViewBag.Region = "Environment variable REGION must be set to East or West."; } else { ViewBag.Region = _config["REGION"]; } if (x != null) { string strRun = x; if (strRun.ToLower() == "true" || strRun.ToLower() == "yes" || strRun.ToLower() == "1") { var result = c.CompoundInterestCalculator(); TempData["balance"] = result; } } return(View(c)); }