Esempio n. 1
0
        public IActionResult Index(ScoreConfig config)
        {
            database.SetMaxScores(config.MaxScores);

            // Clear scores?
            if (config.ResetScores)
            {
                database.Clear();
                database.SaveChangesAsync();
            }

            return(RedirectToRoute(new { controller = "Home", action = "Index" }));
        }
Esempio n. 2
0
        public async Task <string> Post(ScoreEntry value)
        {
            if (value != null)
            {
                database.Add(value);
                await database.SaveChangesAsync();

                return("Success");
            }
            else
            {
                return("Failed");
            }
        }
Esempio n. 3
0
        public async Task <IActionResult> Submit(ScoreEntry entry)
        {
            // Check if the result is valid
            if (!ModelState.IsValid)
            {
                return(View(entry));
            }

            // Save the entry asynchronously
            database.Add(entry);
            await database.SaveChangesAsync();

            // Redirect to the Entry Action with an Anonymous Parameter that Entry() needs
            return(RedirectToAction("Index"));
        }