public async Task <ActionResult> DeleteConfirmed(int id) { GameApiLink gameApiLink = await db.Games.FindAsync(id); db.Games.Remove(gameApiLink); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
public async Task <ActionResult> EditGameDetails([Bind(Include = "Id,GameIdentifier,Name")] GameApiLink gameApiLink) { if (ModelState.IsValid) { db.Entry(gameApiLink).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View("Edit", gameApiLink)); }
// GET: Games/Edit/5 public async Task <ActionResult> Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } GameApiLink gameApiLink = await db.Games.FindAsync(id); if (gameApiLink == null) { return(HttpNotFound()); } return(View(gameApiLink)); }
public async Task <ActionResult> AddGameToDb(int id) { var igdbService = new IGDBService(); var game = await igdbService.GetGameDetailsAsync(id); var gameApiLink = new GameApiLink { Name = game.Name, GameIdentifier = game.Id, GenreIds = game.GenreIds }; db.Games.Add(gameApiLink); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }