public Cell[] Start(Coordinates[] ListInitialCells, Game game)
        {
            inputGrid = new Grid(inputGrid.GridWidth, inputGrid.GridHeight);
            for (int x = 0; x < inputGrid.GridHeight; x++)
            {
                Row newRow = new Row();

                for (int y = 0; y < inputGrid.GridWidth; y++)
                {
                    Cell newCell = new Cell(new Coordinates(x, y), 0, false, game.StartGame_Id);
                    newCell.type = GridHelper.GetCellType(inputGrid, newCell.Coor);
                    newRow.CellsList.Add(newCell);
                }
                inputGrid.RowsList.Add(newRow);
            }
            foreach (Coordinates coor in ListInitialCells)
            {
                //inputGrid[coor.X, coor.Y].IsAlive = true;
                ListAmendedCell.Add(inputGrid[coor.X, coor.Y]);
            }
            return ListAmendedCell.ToArray();
        }
 public void SaveGame(Game game)
 {
     if (game != null)
     {
         try
         {
             repository.GameList.Add(game);
             repository.SaveChanges();
         }
         catch (DbEntityValidationException dbEx)
         {
             foreach (var validationErrors in dbEx.EntityValidationErrors)
             {
                 foreach (var validationError in validationErrors.ValidationErrors)
                 {
                     Trace.TraceInformation("Property: {0} Error: {1}", validationError.PropertyName, validationError.ErrorMessage);
                 }
             }
         }
     }
     else throw new ArgumentNullException("The parameter game cannot be null");
 }
 public void SaveGame(Game game)
 {
     DAL dal = new DAL();
     dal.SaveGame(game);
 }
        public JsonResult Start(string coor)
        {
            //Gonvert coordenates from string to Coordinates[]
            var serializer = new JavaScriptSerializer();

            CurrentGame = new Game(DateTime.Now);
            List<Coordinates> coorList = new List<Coordinates>();
            try
            {
                var jsoncoor = (Object[])serializer.Deserialize<object>(coor);
                foreach (dynamic item in jsoncoor)
                {
                    coorList.Add(new Coordinates(Convert.ToInt16(item["X"]), Convert.ToInt16(item["Y"])));
                }
            }
            catch (Exception)
            {
                return Json(false);
            }
            //Initialize the cell grid and get the cells to update
            Cell[] ChangedStatusCells = Generationsgame.Start(coorList.ToArray(), CurrentGame);
            //Update the cells state
            Generationsgame.UpdateGrid(ChangedStatusCells);
            //Create a new entry for the current game
            MainController.repository.SaveGame(CurrentGame);
            return Json(true);
        }