public GuessingController()
        {
            _context = new ApplicationDbContext();
            _service = new GuessingService(_context);

            _guessingSet = _context.TranslationRows
                           .Where(tr => tr.GuessAttempts.Count < 3)
                           .ToDictionary(tr => tr.Id);

            _sourceLanguageGuid = Guid.Parse(ConfigurationManager.AppSettings["SourceLanguage"]);
            _targetLanguageGuid = Guid.Parse(ConfigurationManager.AppSettings["DestinationLanguage"]);
        }
Beispiel #2
0
        public IActionResult TestNumber(int userGuess)
        {
            if (HttpContext.Session.GetInt32("numberToGuess") == null)
            {
                HttpContext.Session.SetInt32("numberToGuess", new Random().Next(1, 101));
            }


            int numberToGuess = (int)HttpContext.Session.GetInt32("numberToGuess");

            ViewBag.number = GuessingService.CheckNumber(userGuess, numberToGuess);

            if (numberToGuess == userGuess)
            {
                HttpContext.Session.SetInt32("numberToGuess", new Random().Next(1, 101));
            }

            return(View());
        }