Example #1
0
        /// <summary>
        /// takes all the variables needed to resume the game, puts them into a dto and uploads to database.
        /// </summary>
        /// <returns>view</returns>
        public IActionResult SaveGame()
        {
            GameData       gd   = new GameData();
            List <GameDTO> game = new List <GameDTO>();

            foreach (Cell cell in cellList)
            {
                GameDTO gdto = new GameDTO();
                gdto.Id            = cell.Id;
                gdto.row           = cell.row;
                gdto.col           = cell.col;
                gdto.visited       = cell.visited;
                gdto.live          = cell.live;
                gdto.flagged       = cell.flagged;
                gdto.liveNeighbors = cell.liveNeighbors;
                gdto.PlayerId      = UserID;
                gdto.Time          = cb.stopTimer();
                gdto.Clicks        = clickCount;
                game.Add(gdto);
            }
            gd.SaveGame(game, UserID);
            return(RedirectToAction("Index", "Board"));
        }