public async Task <IActionResult> Edit(int id, [Bind("AppID,AppName,AppURL,AppDescription,AppStatus,DateCreated")] Application application) { if (id != application.AppID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(application); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ApplicationExists(application.AppID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(application)); }
public void HideGame([FromBody] HideGameRequest req) { using (var db = new ChecklistContext()) { var game = db.Find <Game>(req.GameId); game.Hidden = true; db.Update(game); db.SaveChanges(); } }
public void LoadGames() { var ownedGames = AsyncHelper.RunSync(() => GetGames(userId)); using var db = new ChecklistContext(); foreach (var game in ownedGames.OwnedGames) { var g = db.Find <Game>(Convert.ToInt64(game.AppId)); var played = 0; if (game.PlaytimeLastTwoWeeks.HasValue) { played = (int)game.PlaytimeLastTwoWeeks.Value.TotalMinutes; } if (g == null) { db.Add(new Game { Id = game.AppId, Name = game.Name, Playtime2Weeks = played, PlaytimeForever = (int)game.PlaytimeForever.TotalMinutes, Image = game.ImgLogoUrl, Hidden = false, }); } else { g.Playtime2Weeks = played; g.PlaytimeForever = (int)game.PlaytimeForever.TotalMinutes; db.Update(g); } } db.SaveChanges(); }