public IActionResult Reset() { int getRnd = RandomNumberGuess.GetRandom(100); HttpContext.Session.SetInt32("intRnd", getRnd); ViewBag.Rnd = getRnd; return(RedirectToAction(nameof(GuessingGame))); }
public IActionResult GuessingGame() { if (string.IsNullOrEmpty(HttpContext.Session.GetString("intRnd"))) { int getRnd = RandomNumberGuess.GetRandom(100); HttpContext.Session.SetInt32("intRnd", getRnd); ViewBag.Rnd = getRnd; } else if (true) { ViewBag.Rnd = HttpContext.Session.GetInt32("intRnd"); } return(View()); }
public IActionResult GuessingGame(int userGuess) { if (!string.IsNullOrEmpty(HttpContext.Session.GetString("intRnd")) && userGuess > 0 && userGuess < 100) { int storedRnd = (int)HttpContext.Session.GetInt32("intRnd"); string respons = RandomNumberGuess.MatchGuess(Convert.ToInt32(userGuess), storedRnd); ViewBag.Msg = respons; } else { ViewBag.Msg = "Enter a number between 1 and 99 and hit Submit"; } return(View()); }