Пример #1
0
 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());
     }
 }
Пример #2
0
 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();
     }
 }
Пример #3
0
 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();
        }
Пример #5
0
 public BaseRepository(ChecklistContext checklistContext)
 {
     _checklistContext = checklistContext;
     _dbset            = _checklistContext.Set <T>();
 }
Пример #6
0
 public ChecklistController(ChecklistContext context)
 {
     _context = context;
 }
Пример #7
0
 public ApplicationsController(ChecklistContext context)
 {
     _context = context;
 }
Пример #8
0
 public void Setup()
 {
     _optionsBuilder = new DbContextOptionsBuilder <ChecklistContext>();
     _optionsBuilder.UseInMemoryDatabase(DateTime.UtcNow + "_Database");
     _context = new ChecklistContext(_optionsBuilder.Options);
 }
Пример #9
0
 public UnitOfWork(ChecklistContext checklistContext)
 {
     _checklistContext = checklistContext;
 }