示例#1
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,GameID,ListID")] GameListModel gameListModel)
        {
            if (id != gameListModel.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(gameListModel);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!GameListModelExists(gameListModel.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["GameID"] = new SelectList(_context.Games, "ID", "GameStatus", gameListModel.GameID);
            ViewData["ListID"] = new SelectList(_context.Lists, "ListID", "ListID", gameListModel.ListID);
            return(View(gameListModel));
        }
示例#2
0
        public IActionResult Edit(int id, [Bind("Id,Cover,Developer,FirstReleaseDate,Publisher,ReleaseDateNA,ReleaseDateEU,ReleaseDateJP, Platform, ScreenShot")] GameListModel gameListModel)
        {
            //Save screenshots
            if (gameListModel.ScreenShot != null && gameListModel.ScreenShot.Count() > 0)
            {
                _fileHandler.SaveFile(id.ToString(), gameListModel.ScreenShot);
            }

            if (id != gameListModel.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _unitOFWork.GameRepo.Update(gameListModel);
                    _unitOFWork.Commit();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!GameListModelExists(gameListModel.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
            }
            return(RedirectToAction(nameof(Edit) + "/" + id));
        }
示例#3
0
 public NationalRankingModel(GameListModel GameList, int year, string chartmap)
 {
     Games     = GameList;
     Year      = year;
     ChartPath = "/national-ranking/ranking-chart/" + year;
     ChartMap  = chartmap;
 }
示例#4
0
 public IActionResult Create([Bind("Id,Cover,Developer,FirstReleaseDate,Publisher,ReleaseDateNA,ReleaseDateEU,ReleaseDateJP,Platform, ScreenShot")] GameListModel gameListModel)
 {
     if (ModelState.IsValid)
     {
         _unitOFWork.GameRepo.Insert(gameListModel);
         _unitOFWork.Commit();
         return(RedirectToAction(nameof(Index)));
     }
     return(View(gameListModel));
 }
示例#5
0
        public async Task <IActionResult> Create([Bind("ID,GameID,ListID")] GameListModel gameListModel)
        {
            if (ModelState.IsValid)
            {
                _context.Add(gameListModel);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["GameID"] = new SelectList(_context.Games, "ID", "GameStatus", gameListModel.GameID);
            ViewData["ListID"] = new SelectList(_context.Lists, "ListID", "ListID", gameListModel.ListID);
            return(View(gameListModel));
        }
示例#6
0
        public async Task <GameListModel> GetByID(string id)
        {
            #region Setup Http client
            client.DefaultRequestHeaders.Accept.Clear();
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            client.DefaultRequestHeaders.Add("user-key", "b0d327604a696f914cafb0a23d782e6f");
            #endregion

            string queryString = string.Format("https://api-endpoint.igdb.com/games/{0}?fields=*", id);

            var msg = await client.GetStringAsync(queryString);

            IEnumerable <GameListModel> mappedResult = JsonConvert.DeserializeObject <IEnumerable <GameListModel> >(msg);

            GameListModel result = mappedResult.FirstOrDefault();

            return(result);
        }
示例#7
0
        public ActionResult Index()
        {
            GameListModel model = new GameListModel();

            model.Games = new List <GameModel>();

            var con = ConfigurationManager.ConnectionStrings["DefaultConnection"].ToString();

            using (SqlConnection myConnection = new SqlConnection(con))
            {
                string editString = "SELECT Games.GameId,Games.Title,AspNetUsers.Name,Games.GameDescription FROM Games, AspNetUsers WHERE Games.Author = AspNetUsers.UserName";
                myConnection.Open();

                DataSet        ds      = new DataSet();
                SqlCommand     cmd     = new SqlCommand(editString, myConnection);
                SqlDataAdapter adapter = new SqlDataAdapter();
                adapter.SelectCommand = cmd;
                adapter.Fill(ds);
                myConnection.Close();

                for (int i = 0; i <= ds.Tables[0].Rows.Count - 1; i++)
                {
                    var       row  = ds.Tables[0].Rows[i].ItemArray;
                    GameModel game = new GameModel
                    {
                        GameId      = (int)row[0],
                        Title       = row[1].ToString(),
                        Author      = row[2].ToString(),
                        Description = row[3].ToString()
                    };
                    model.Games.Add(game);
                }

                return(View(model));
            }
        }
 public RosterModel(GameListModel GameList, List <PlayerModel> PlayerModelLst)
 {
     Games   = GameList;
     Players = PlayerModelLst;
 }
示例#9
0
 /// <summary>
 /// Initializes a new instance of the GameListViewModel class
 /// </summary>
 /// <param name="model">Model to be used by the GameListViewModel</param>
 public GameListViewModel(GameListModel model)
 {
     this.model = model;
 }
示例#10
0
        public ActionResult Index()
        {
            GameListModel games = new GameListModel(_gamesBL.GamesBySeason(KSU.maxGameSeason));

            return(View(games));
        }