public void PlayerCharacterAdd(Guid playerId, int characterId)
 {
     using (var entities = new GinTubEntities())
     {
         entities.PlayerCharacterAdd(playerId, characterId);
     }
 }
 public void PlayerEventAdd(Guid playerId, int eventId)
 {
     using (var entities = new GinTubEntities())
     {
         entities.PlayerEventAdd(playerId, eventId);
     }
 }
 public IEnumerable<Result> GetMessageChoiceResults(int messageChoiceId)
 {
     IEnumerable<Result> results = null;
     using (var entities = new GinTubEntities())
     {
         var resultResults = entities.GetMessageChoiceResults(messageChoiceId);
         results = resultResults.Select(r => TypeAdapter.Adapt<Result>(r)).ToList();
     }
     return results;
 }
 public IEnumerable<Result> GetActionResults(Guid playerId, int nounId, int verbTypeId)
 {
     IEnumerable<Result> results = null;
     using(var entities = new GinTubEntities())
     {
         var resultResults = entities.GetActionResults(playerId, nounId, verbTypeId);
         results = resultResults.Select(r => TypeAdapter.Adapt<Result>(r)).ToList();
     }
     return results;
 }
 public GameData ReadGame(Guid playerId)
 {
     GameData gameData = null;
     using (var entities = new GinTubEntities())
     {
         var gameStateResults = entities.ReadGame(playerId);
         gameData = GameAndAreaAndRoomResultsFromDb(gameStateResults);
     }
     return gameData;
 }
 public IEnumerable<InventoriesEntry> ReadPartyForPlayer(Guid playerId)
 {
     IEnumerable<InventoriesEntry> results = null;
     using (var entities = new GinTubEntities())
     {
         var resultResults = entities.ReadPartyForPlayer(playerId);
         results = resultResults.Select(r => TypeAdapter.Adapt<InventoriesEntry>(r)).ToList();
     }
     return results;
 }
 public Task UpdateLastTime(Guid playerId, int nounId, int verbTypeId, TimeSpan time)
 {
     return Task.Run(() =>
         {
             using (var entities = new GinTubEntities())
             {
                 entities.UpdateLastTimeForPlayer(playerId, nounId, verbTypeId, time);
             }
         });
 }
        public Message ReadMessage(int messageId)
        {
            Message message = null;
            using(var entities = new GinTubEntities())
            {
                var messageResult = entities.ReadMessageForPlayer(messageId);
                message = messageResult.Select(m => TypeAdapter.Adapt<Message>(m)).First();

                var messageChoiceResults = messageResult.GetNextResult<ReadMessageChoicesForMessage_Result>();
                if(messageChoiceResults != null)
                    message.MessageChoices = messageChoiceResults.Select(mc => TypeAdapter.Adapt<MessageChoice>(mc)).ToArray();
            }
            return message;
        }
 public IEnumerable<Noun> ReadNounsForParagraphState(int paragraphStateId)
 {
     IEnumerable<Noun> nouns = null;
     using(var entities = new GinTubEntities())
     {
         var nounResults = entities.ReadNounsForParagraphState(paragraphStateId);
         nouns = nounResults.Select(n => TypeAdapter.Adapt<Noun>(n)).ToList();
     }
     return nouns;
 }
 public void PlayerItemAdd(Guid playerId, int itemId)
 {
     using(var entities = new GinTubEntities())
     {
         entities.PlayerItemAdd(playerId, itemId);
     }
 }
 public RoomData PlayerRoomStateChange(Guid playerId, int roomId, int state)
 {
     RoomData roomData = null;
     using (var entities = new GinTubEntities())
     {
         var roomResults = entities.PlayerRoomStateChange(playerId, roomId, state);
         roomData = RoomResultsFromDB(roomResults);
     }
     return roomData;
 }
 public IEnumerable<VerbType> ReadAllVerbTypes()
 {
     IEnumerable<VerbType> verbTypes = null;
     using (var entities = new GinTubEntities())
     {
         var verbTypeResults = entities.ReadAllVerbTypes();
         verbTypes = verbTypeResults.Select(v => TypeAdapter.Adapt<VerbType>(v)).ToList();
     }
     return verbTypes;
 }
 public AreaData PlayerTeleportAreaIdRoomId(Guid playerId, int areaId, int roomId)
 {
     AreaData areaData = null;
     using (var entities = new GinTubEntities())
     {
         var areaResults = entities.PlayerTeleportAreaIdRoomId(playerId, areaId, roomId);
         areaData = AreaAndRoomResultsFromDb(areaResults);
     }
     return areaData;
 }
 public IEnumerable<ResultType> ReadAllResultTypes()
 {
     IEnumerable<ResultType> resultTypes = null;
     using (var entities = new GinTubEntities())
     {
         var resultTypeResults = entities.ReadAllResultTypes();
         resultTypes = resultTypeResults.Select(v => TypeAdapter.Adapt<ResultType>(v)).ToList();
     }
     return resultTypes;
 }
 public IEnumerable<Audio> ReadAllAudio()
 {
     IEnumerable<Audio> audio = null;
     using (var entities = new GinTubEntities())
     {
         var audioResults = entities.ReadAllAudio();
         audio = audioResults.Select(v => TypeAdapter.Adapt<Audio>(v)).ToList();
     }
     return audio;
 }
 public RoomData PlayerTeleportRoomXYZ(Guid playerId, int xPos, int yPos, int zPos)
 {
     RoomData roomData = null;
     using (var entities = new GinTubEntities())
     {
         var roomResults = entities.PlayerTeleportRoomXYZ(playerId, xPos, yPos, zPos);
         roomData = RoomResultsFromDB(roomResults);
     }
     return roomData;
 }
 public RoomData PlayerTeleportRoomID(Guid playerId, int roomId)
 {
     RoomData roomData = null;
     using (var entities = new GinTubEntities())
     {
         var roomResults = entities.PlayerTeleportRoomId(playerId, roomId);
         roomData = RoomResultsFromDB(roomResults);
     }
     return roomData;
 }
 public AreaData PlayerTeleportAreaIdRoomXYZ(Guid playerId, int areaId, int xPos, int yPos, int zPos)
 {
     AreaData areaData = null;
     using (var entities = new GinTubEntities())
     {
         var areaResults = entities.PlayerTeleportAreaIdRoomXYZ(playerId, areaId, xPos, yPos, zPos);
         areaData = AreaAndRoomResultsFromDb(areaResults);
     }
     return areaData;
 }
 public GameState ReadGameStateForPlayer(Guid playerId)
 {
     GameState gameState = null;
     using (var entities = new GinTubEntities())
     {
         var gameStateResults = entities.ReadGameStateForPlayer(playerId);
         gameState = TypeAdapter.Adapt<GameState>(gameStateResults.SingleOrDefault());
     }
     return gameState;
 }
 public Tuple<Area, IEnumerable<MapEntry>> ReadMapForPlayer(Guid playerId, int areaId)
 {
     Area area = null;
     IEnumerable<MapEntry> results = null;
     using (var entities = new GinTubEntities())
     {
         var areaResults = entities.ReadAreaForPlayer(areaId);
         area = areaResults.Select(a => TypeAdapter.Adapt<Area>(a)).FirstOrDefault();
         var resultResults = entities.ReadMapForPlayer(playerId, areaId);
         results = resultResults.Select(r => TypeAdapter.Adapt<MapEntry>(r)).ToList();
     }
     return new Tuple<Area,IEnumerable<MapEntry>>(area, results);
 }
 public Guid? PlayerLogin(string userName, string domainName, string domain, string password)
 {
     Guid? playerId = null;
     using (var entities = new GinTubEntities())
     {
         var results = entities.PlayerLogin(userName, domainName, domain, password);
         playerId = results.OfType<Guid?>().SingleOrDefault();
     }
     return playerId;
 }
 public RoomData PlayerMoveXYZ(Guid playerId, int xDir, int yDir, int zDir)
 {
     RoomData roomData = null;
     using(var entities = new GinTubEntities())
     {
         var roomResults = entities.PlayerMoveXYZ(playerId, xDir, yDir, zDir);
         roomData = RoomResultsFromDB(roomResults);
     }
     return roomData;
 }