예제 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("MyGamesId,GameID,ReviewGrade,Review,ReviewDate")] MyGames myGames)
        {
            if (id != myGames.MyGamesId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(myGames);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!MyGamesExists(myGames.MyGamesId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["GameID"] = new SelectList(_context.Game, "GameId", "GameId", myGames.GameID);
            return(View(myGames));
        }
예제 #2
0
 public ActionResult EditDisplay([Bind(Include = "ID,Name,Genre, Price")] MyGames myGames)
 {
     if (ModelState.IsValid)
     {
         db.Entry(myGames).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Display"));
     }
     return(View(myGames));
 }
예제 #3
0
 public static void Load()
 {
     if (File.Exists(Application.persistentDataPath + "/SavedGames.data"))
     {
         BinaryFormatter bf   = new BinaryFormatter();
         FileStream      file = File.Open(Application.persistentDataPath + "/SavedGames.data", FileMode.Open);
         SaveLoadGame.game = (MyGames)bf.Deserialize(file);
         file.Close();
     }
 }
예제 #4
0
        public async Task <IActionResult> Create([Bind("MyGamesId,GameID,ReviewGrade,Review,ReviewDate")] MyGames myGames)
        {
            if (ModelState.IsValid)
            {
                _context.Add(myGames);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["GameID"] = new SelectList(_context.Game, "GameId", "GameId", myGames.GameID);
            return(View(myGames));
        }
예제 #5
0
        //GET: Student/Edit/5
        public ActionResult EditDisplay(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            MyGames myGames = db.Games.Find(id);

            if (myGames == null)
            {
                return(HttpNotFound());
            }
            return(View(myGames));
        }
예제 #6
0
 public ActionResult DeleteConfirmed(int id)
 {
     try
     {
         MyGames myGames = db.Games.Find(id);
         db.Games.Remove(myGames);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     catch (DataException)
     {
         return(RedirectToAction("Delete", new { id = id, saveChangesError = true }));
     }
 }
예제 #7
0
 public ActionResult Edit([Bind(Include = "ID,Name,Genre,Price")] MyGames myGames)
 {
     try
     {
         if (ModelState.IsValid)
         {
             db.Entry(myGames).State = EntityState.Modified;
             db.SaveChanges();
             return(RedirectToAction("Index"));
         }
     }
     catch (DataException)
     {
         ModelState.AddModelError("", "Unable to save changes. Try again. If problem persits contact the system administrator");
     }
     return(View(myGames));
 }
예제 #8
0
        // GET: MyGames/Delete/5
        public ActionResult Delete(int?id, bool?saveChangesError = false)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            if (saveChangesError.GetValueOrDefault())
            {
                ViewBag.ErrorMessage = "Delete failed. Try again, if the problem persists please contact the system administrator.";
            }
            MyGames myGames = db.Games.Find(id);

            if (myGames == null)
            {
                return(HttpNotFound());
            }
            return(View(myGames));
        }
예제 #9
0
    public void LoadGames()                                                                                                        //this should be ran in the beginning of the game
    {
        MyGames curGames = new MyGames();                                                                                          //creates a new MyGames object which stores all of the data for each Game

        if (File.Exists(Application.persistentDataPath + saveDataFile + saveDataFileEnding))                                       //check if we have a file to open (the game has been played before)
        {
            BinaryFormatter loadBf = new BinaryFormatter();                                                                        //open a BinaryFormatter
            FileStream      loadFS = File.Open(Application.persistentDataPath + saveDataFile + saveDataFileEnding, FileMode.Open); //Open a file in our persistent Data Path location
            curGames = (MyGames)loadBf.Deserialize(loadFS);                                                                        //Deserialize our saved game dat file and store it into curStats
        }
        else                                                                                                                       //if we don't have a game save, create a new one
        {
            curGames.GameOne   = CreateNewSave();
            curGames.GameTwo   = CreateNewSave();
            curGames.GameThree = CreateNewSave();

            _myGames = curGames;

            Save();             //save the new game as a new file
        }

        _myGames = curGames;
    }
예제 #10
0
    public void GetSavedGames()
    {
        //Get saved games is ran during the game select screen, this grabs the base file
        //of all of our game saves
        myLoadedGames.Clear (); //my loaded games is a list that holds games 1-3, we store those in a static list for easy access
        if (_gamesInstance == null) {
            _gamesInstance = new MyGames (); //if we don't have an instance of _gamesIntance, make a new one
            //just to store data in when we load the file
        }
        if (GameSaver == null) {
            GameSaver = SaveGame.GetGameSaver; //if we don't have a refrence to the GameSaver, get one
            //This will also make GameSaver finding itself it has not yet
            //found an instance of itself
        }

        _gamesInstance = GameSaver.GetMyGames ();
        //GameSaver.GetMyGames will return our full save file, which are storing in the
        //local variable, _gamesInstance

        myLoadedGames.Add (_gamesInstance.GameOne); //once we have our game file, add each save to the list
        myLoadedGames.Add (_gamesInstance.GameTwo); //we don't technically need to do this, I was just doing it
        myLoadedGames.Add (_gamesInstance.GameThree); //for ease of testing.
    }
예제 #11
0
    public void GetSavedGames()      //Get saved games is ran during the game select screen, this grabs the base file
    //of all of our game saves
    {
        myLoadedGames.Clear();          //my loaded games is a list that holds games 1-3, we store those in a static list for easy access
        if (_gamesInstance == null)
        {
            _gamesInstance = new MyGames();              //if we don't have an instance of _gamesIntance, make a new one
            //just to store data in when we load the file
        }
        if (GameSaver == null)
        {
            GameSaver = SaveGame.GetGameSaver;             //if we don't have a refrence to the GameSaver, get one
            //This will also make GameSaver finding itself it has not yet
            //found an instance of itself
        }

        _gamesInstance = GameSaver.GetMyGames();
        //GameSaver.GetMyGames will return our full save file, which are storing in the
        //local variable, _gamesInstance

        myLoadedGames.Add(_gamesInstance.GameOne);          //once we have our game file, add each save to the list
        myLoadedGames.Add(_gamesInstance.GameTwo);          //we don't technically need to do this, I was just doing it
        myLoadedGames.Add(_gamesInstance.GameThree);        //for ease of testing.
    }