private bool RunnerExists(int id) { using (var context = new GameReviewRunningContext()) { return(context.Runners.Any(r => r.Id == id)); } }
public async Task <IActionResult> EditRunner(int id, [Bind("Id, RunnerName, Age, WorldRecords")] Runner runner) { if (id != runner.Id) { return(NotFound()); } using (var context = new GameReviewRunningContext()) { if (ModelState.IsValid) { try { context.Runners.Update(runner); await context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RunnerExists(runner.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction("Index")); } return(View(runner)); } }
public async Task <IActionResult> EditGame(int id, [Bind("Id,Title,Developer,ReleaseDate, WorldRecord")] Game game) { if (id != game.Id) { return(NotFound()); } using (var context = new GameReviewRunningContext()) { if (ModelState.IsValid) { try { context.Update(game); await context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!GameExists(game.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction("Index")); } return(View(game)); } }
private bool GameExists(int id) { using (var context = new GameReviewRunningContext()) { return(context.Games.Any(g => g.Id == id)); } }
// GET: /<controller>/ public async Task <IActionResult> Index() { using (var context = new GameReviewRunningContext()) { var model = await context.Runners.AsNoTracking().ToListAsync(); return(View(model)); } }
public async Task <IActionResult> CreateGame([Bind("Title, Developer, ReleaseDate, WorldRecord")] Game game) { using (var context = new GameReviewRunningContext()) { context.Games.Add(game); await context.SaveChangesAsync(); return(RedirectToAction("Index")); } }
public async Task <IActionResult> DeleteRunnerConfirmed(int id) { using (var context = new GameReviewRunningContext()) { var runner = await context.Runners.SingleOrDefaultAsync(m => m.Id == id); context.Runners.Remove(runner); await context.SaveChangesAsync(); return(RedirectToAction("Index")); } }
public async Task <IActionResult> CreateRunner([Bind("RunnerName, Age, WorldRecords")] Runner runner) { using (var context = new GameReviewRunningContext()) { if (ModelState.IsValid) { context.Add(runner); await context.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View()); } }
public async Task <IActionResult> DetailsRunner(int?id) { if (id == null) { return(NotFound()); } using (var context = new GameReviewRunningContext()) { var runner = await context.Runners.SingleOrDefaultAsync(m => m.Id == id); if (runner == null) { return(NotFound()); } return(View(runner)); } }
public async Task <IActionResult> DeleteGame(int?id) { if (id == null) { return(NotFound()); } using (var context = new GameReviewRunningContext()) { var game = await context.Games.SingleOrDefaultAsync(m => m.Id == id); if (game == null) { return(NotFound()); } return(View(game)); } }
public async Task <IActionResult> EditRunner(int?id) { if (id == null) { return(NotFound()); } using (var context = new GameReviewRunningContext()) { ViewBag.Games = context.Games.ToList(); var runner = await context.Runners.SingleOrDefaultAsync(g => g.Id == id); if (runner == null) { return(NotFound()); } return(View(runner)); } // return View(game); }