public IEnumerable <Game> AllGames() { using (var db = new ChecklistContext()) { return(db.Games.Where(g => !g.Hidden) .OrderByDescending(g => g.Playtime2Weeks) .ThenByDescending(g => g.PlaytimeForever).ToList()); } }
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 Stats Stats() { using (var db = new ChecklistContext()) { return(new Stats { TotalGames = db.Games.Count(), FinishedGames = db.Games.Where(g => g.Hidden).Count(), }); } }
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(); }
public BaseRepository(ChecklistContext checklistContext) { _checklistContext = checklistContext; _dbset = _checklistContext.Set <T>(); }
public ChecklistController(ChecklistContext context) { _context = context; }
public ApplicationsController(ChecklistContext context) { _context = context; }
public void Setup() { _optionsBuilder = new DbContextOptionsBuilder <ChecklistContext>(); _optionsBuilder.UseInMemoryDatabase(DateTime.UtcNow + "_Database"); _context = new ChecklistContext(_optionsBuilder.Options); }
public UnitOfWork(ChecklistContext checklistContext) { _checklistContext = checklistContext; }