using System; using System.Web.Mvc; using System.Collections.Generic; namespace HelloWorldMvcApp { public class HomeController : Controller { [HttpGet] public ActionResult Index() { return View(new SampleViewModel()); } [HttpGet] public ActionResult RetornarQuadrado(double? numero) { double resposta = Math.Pow(numero.Value, (double)2); return Content($"O quadrado do número {numero} é: {resposta}"); } [HttpPost] public JsonResult GetAnswer(string question) { int index = _rnd.Next(_db.Count); var answer = _db[index]; return Json(answer); } private static Random _rnd = new Random(); private static List _db = new List { "Yes", "No", "Definitely, yes", "I don't know", "Looks like, yes"} ; } }