using Microsoft.AspNetCore.Mvc;
namespace MVCWebApp.Controllers
{
public class FinancialController : Controller
{
public IActionResult Index()
{
ViewData["Message"] = "Enter the loan amount details:";
//
Return the Razor View "SimpleInterest.cshtml"
return View("SimpleInterest");
}
[HttpPost]
public IActionResult CalculateInterest()
{
double principle = double.Parse(Request.Form["txtAmount"].ToString());
double rate = double.Parse(Request.Form["txtRate"].ToString());
int term = int.Parse(Request.Form["txtTerm"].ToString());
double interest = (principle * term * rate) / 100;
string message = "Amount:
" + principle.ToString("C2") + "<br />" +
"Rate: " + rate.ToString("C2") + "% <br />" +
"Term: " + term.ToString()
+ " years <br />" +
"Interest: " + interest.ToString("C2");
ViewData["Message"] = message;
// Return the Razor View "SimpleInterest.cshtml"
return View("SimpleInterest");
}
}
}