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" })); }
public async Task <string> Post(ScoreEntry value) { if (value != null) { database.Add(value); await database.SaveChangesAsync(); return("Success"); } else { return("Failed"); } }
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")); }