コード例 #1
0
        public async Task <IActionResult> Create([Bind("AppID,AppName,AppURL,AppDescription,AppStatus,DateCreated")] Application application)
        {
            if (ModelState.IsValid)
            {
                _context.Add(application);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(application));
        }
コード例 #2
0
        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();
        }