// GET api/gameplayer/5 public async Task<Result> Get(string id) { try { GamePlayerStorageInformation storageInfo = new GamePlayerStorageInformation(id.ToString()); GamePlayer player = await ConfigurableDataProvider.Instance .Get<GamePlayer, GamePlayerCacheable, GamePlayerTableStorage>(storageInfo); if (player == null) { return new Result { ErrorCode = ErrorCode.ERROR_RETRIEVING_ACCOUNT }; } GamePlayerAPIMorph morph = new GamePlayerAPIMorph(); return new Result { ErrorCode = ErrorCode.ERROR_OK, Item = morph.ToAPIFormat(player) }; } catch (Exception) { return new Result { ErrorCode = ErrorCode.ERROR_RETRIEVING_ACCOUNT }; } }
/// <summary> /// Returns a string that represents the GamePlayer instance. /// </summary> /// <param name="items"></param> /// <returns></returns> public string PlayerToJSON(GamePlayer item) { GamePlayerAPIMorph morph = new GamePlayerAPIMorph(); return Converter.Serlialize<GamePlayerAPI>((GamePlayerAPI)morph.ToAPIFormat(item)); }
/// <summary> /// Returns a GamePlayer as represented by the supplied json string. /// </summary> /// <param name="json"></param> /// <returns></returns> public GamePlayer PlayerFromJSON(string json) { GamePlayerAPIMorph morph = new GamePlayerAPIMorph(); return (GamePlayer)morph.ToBusinessFormat( Converter.Deserialize<GamePlayerAPI>(json)); }