//GET: Details/id
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpNotFoundResult());
            }
            GamesCollection selectedGame = _gamesCollection.First(g => g.GameID == id);

            if (selectedGame == null)
            {
                return(new HttpNotFoundResult());
            }


            User user = new User
            {
                UserID    = 1,
                FirstName = "Steve",
                LastName  = "Jobs"
            };
            UserGameViewModel viewModel = new UserGameViewModel
            {
                User            = user,
                GamesCollection = selectedGame
            };

            return(View(viewModel));
        }
Exemple #2
0
        public void GameName()
        {
            GamesCollectionsController controller = new GamesCollectionsController();
            ViewResult      viewResult            = controller.Games();
            GamesCollection result = viewResult.Model as GamesCollection;

            Assert.AreEqual("Call of Duty", result.GameName);
        }
        public ActionResult DeleteConfirmed(int id)
        {
            GamesCollection gamesCollection = db.GamesCollections.Find(id);

            db.GamesCollections.Remove(gamesCollection);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemple #4
0
        public GamesCollection listarGames()
        {
            GamesCollection lista      = new GamesCollection();
            GamesDbContext  dbContext  = new GamesDbContext();
            var             listaGames = dbContext.GamesDb;


            return(lista);
        }
 public ActionResult Edit([Bind(Include = "Id,GameID,GameDeveloper,GameGenre,GameName,GameDescription,GameScore,GameAgeRating,Games")] GamesCollection gamesCollection)
 {
     if (ModelState.IsValid)
     {
         db.Entry(gamesCollection).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(gamesCollection));
 }
Exemple #6
0
 public async Task <IActionResult> GetGameDetails(int?gameId)
 {
     try
     {
         return(Ok(await GamesCollection.GetGameDetails(gameId)));
     }
     catch
     {
         return(BadRequest());
     }
 }
        public ActionResult Create([Bind(Include = "Id,GameID,GameDeveloper,GameGenre,GameName,GameDescription,GameScore,GameAgeRating,Games")] GamesCollection gamesCollection)
        {
            if (ModelState.IsValid)
            {
                db.GamesCollections.Add(gamesCollection);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(gamesCollection));
        }
Exemple #8
0
 public async Task <IActionResult> GetGameCollections(int?gameCollectionId)
 {
     try
     {
         return(Ok(await GamesCollection.GetGameCollections(gameCollectionId)));
     }
     catch (Exception ex)
     {
         return(BadRequest());
     }
 }
Exemple #9
0
        private void FetchGames(object state)
        {
            var json = _fetcher.Fetch();

            JObject o = JObject.Parse(json); // parse as array

            var matches = o["data"]["match"];

            GamesCollection.ClearWorking();


            // Go over return value from the site,
            foreach (var match in matches)
            {
                //Create Game Key
                StringBuilder gameKey = new StringBuilder(50);
                gameKey.Append(match["home_name"] + "_" + match["away_name"] + "_" + match["league_name"]);
                Game game = new Game
                {
                    Home   = match["home_name"].ToString(),
                    Away   = match["away_name"].ToString(),
                    League = match["league_name"].ToString(),
                    Key    = gameKey.ToString()
                };

                try
                {
                    // Add into memory Hash
                    GamesCollection.AddGame(game);

                    // Immediately adds a game to mongo for consistency
                    _repository.Create(game);
                }
                catch (Exception e)
                {
                    //Remove from Collection
                    GamesCollection.RemoveGame(game.Key);
                    _logger.LogError(e.Message);
                }

                //Log
                _logger.LogInformation(match.ToString());
            }

            // Now get the games that are not longer in the site.
            var listGamesToDelete = GamesCollection.GetToDeleteGames();

            // and delete the from DB
            _repository.DeleteBulk(listGamesToDelete);

            //swap collections so the reading will be from a collection that is not being changed.
            GamesCollection.SwapCollections();
        }
Exemple #10
0
        // GET: Details/id
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpNotFoundResult());
            }
            GamesCollection selectedGames = _gamesCollection.First(g => g.GameID == id);

            if (selectedGames == null)
            {
                return(new HttpNotFoundResult());
            }
            return(View(selectedGames));
        }
        // GET: GamesList/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            GamesCollection gamesCollection = db.GamesCollections.Find(id);

            if (gamesCollection == null)
            {
                return(HttpNotFound());
            }
            return(View(gamesCollection));
        }
Exemple #12
0
        public void GameAgeRatingIsUnder18()
        {
            GamesCollection model = new GamesCollection();

            model.GameName        = "Test Game 1";
            model.GameDescription = "Description of Test Game 1";
            model.GameAgeRating   = 18;

            GamesCollectionsController controller = new GamesCollectionsController(model);

            ViewResult result = controller.Games();

            Assert.AreEqual(model.GameAgeRating = 18, result.ViewBag.SubTitle);
        }
 public ActionResult Edit(GamesCollection gamesCollection)
 {
     if (ModelState.IsValid)
     {
         Debug.WriteLine(gamesCollection.GameName);
         Debug.WriteLine(gamesCollection.GameDescription);
         Debug.WriteLine(gamesCollection.GameGenre);
         Debug.WriteLine(gamesCollection.GameAgeRating);
         Debug.WriteLine(gamesCollection.GameDeveloper);
         Debug.WriteLine(gamesCollection.GameScore);
         return(RedirectToAction("Index"));
     }
     else
     {
         return(View(gamesCollection));
     }
 }
Exemple #14
0
        /// <summary>
        /// Ajoute les fichiers par défaut et charge les fichiers dans les dossiers
        /// </summary>
        public override void Init()
        {
            // Création des collections (par rapport au changement de nom
            MakeCollection(GameDataC.Applications, GamesCollection, _GamesPath);
            MakeCollection(GameDataC.CheatCodes, CheatsCollection, _CheatsPath);
            MakeCollection(GameDataC.Manuals, ManualsCollection, _ManualsPath);
            MakeCollection(GameDataC.Musics, MusicsCollection, _MusicsPath);
            MakeCollection(GameDataC.Videos, VideosCollection, _VideosPath);

            // Initialisation des fichiers par défaut.
            ChosenGame       = GamesCollection.FirstOrDefault(x => x.DestPath.Equals(GameDataC.DefaultApp?.DestPath));
            ChosenManual     = ManualsCollection.FirstOrDefault(x => x.DestPath.Equals(GameDataC?.DefaultManual?.DestPath));
            ChosenMusic      = MusicsCollection.FirstOrDefault(x => x.DestPath.Equals(GameDataC.DefaultMusic?.DestPath));
            ChosenVideo      = VideosCollection.FirstOrDefault(x => x.DestPath.Equals(GameDataC.DefaultVideo?.DestPath));
            ChosenThemeVideo = VideosCollection.FirstOrDefault(x => x.DestPath.Equals(GameDataC.DefaultThemeVideo?.DestPath));

            LoadFiles();
        }
 public ViewResult Games()
 {
     if (game == null)
     {
         game                 = new GamesCollection();
         game.GameName        = "Call Of Duty";
         game.GameDescription = "War shooter that focuses on killing the enemy side";
         game.GameAgeRating   = 18;
     }
     if (game.GameAgeRating > 18)
     {
         ViewBag.SubTitle = "This game is suitable for those under 18 to play ";
     }
     else
     {
         ViewBag.SubTitle = "Only those aged 18 and over may play this game ";
     }
     return(View(game));
 }
 public GamesCollectionsController(GamesCollection model)
 {
     game = model;
 }
 public IActionResult GetGames()
 {
     return(Ok(GamesCollection.GetAllGames()));
 }