public void Remove(HotseatSavedGameInfo savedGameInfo)
        {
            using (DbContextTransaction transaction = Database.BeginTransaction())
            {
                try
                {
                    var objectToBeRemoved = HotseatSavedGameInfos.First(x => x.Id == savedGameInfo.Id);

                    string path = objectToBeRemoved.Path;

                    HotseatSavedGameInfos.Remove(objectToBeRemoved);

                    File.Delete(path);

                    SaveChanges();

                    transaction.Commit();
                }
                catch (Exception)
                {
                    transaction.Rollback();
                    throw;
                }
            }
        }
        public void SaveGame(Game game)
        {
            switch (game.GameType)
            {
            case GameType.SinglePlayer:
            {
                var    savedGames = SingleplayerSavedGameInfos;
                string name       = $"{game.Id}.sav";

                var save     = savedGames.FirstOrDefault(x => x.Id == game.Id);
                var saveInfo = new SingleplayerSavedGameInfo(game.GetBytes())
                {
                    AiNumber      = game.Players.Count - 1,
                    MapName       = game.Map.Name,
                    SavedGameDate = DateTime.Now,
                    Name          = name
                };
                // game hasn't been saved yet

                if (save != null)
                {
                    savedGames.Remove(save);
                }
                savedGames.Add(saveInfo);

                SaveChanges();
                break;
            }

            case GameType.MultiplayerHotseat:
            {
                var    savedGames = HotseatSavedGameInfos;
                string name       = $"{game.Id}.sav";

                var save = savedGames.FirstOrDefault(x => x.Id == game.Id);

                var saveInfo = new HotseatSavedGameInfo(game.GetBytes())
                {
                    Id            = game.Id,
                    MapName       = game.Map.Name,
                    SavedGameDate = DateTime.Now,
                    Name          = name
                };
                if (save != null)
                {
                    savedGames.Remove(save);
                }
                int aiPlayerNumber = (from player in game.Players
                                      where player.GetType() == typeof(AiPlayer)
                                      select player).Count();
                int humanPlayersNumber = game.Players.Count - aiPlayerNumber;

                saveInfo.AiNumber    = aiPlayerNumber;
                saveInfo.HumanNumber = humanPlayersNumber;
                savedGames.Add(saveInfo);

                SaveChanges();

                break;
            }

            case GameType.MultiplayerNetwork:
                throw new NotImplementedException();
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
        public byte[] LoadGame(HotseatSavedGameInfo info)
        {
            var savedGameInfo = HotseatSavedGameInfos.First(x => x.Id == info.Id);

            return(savedGameInfo.GetFileBytes());
        }