Exemplo n.º 1
0
        public async Task <ReturnObject> GetUserMonster()
        {
            ReturnObject ReturnObject;

            MonsterList ml;

            Request.Monster.UsersMonster monsters = new Request.Monster.UsersMonster();
            monsters.SetParam(Token);

            if (App.core.Offline)
            {
                return new ReturnObject()
                       {
                           Content   = MonsterList.GetUserMonsterListFromJson(null, 12),
                           ErrorCode = 0,
                           Message   = string.Empty
                       }
            }
            ;

            try
            {
                ml = MonsterList.GetUserMonsterListFromJson(await monsters.GetJsonAsync());

                ReturnObject = new ReturnObject()
                {
                    Content = ml, ErrorCode = 0, Message = string.Empty
                };
            }
            catch (HttpRequestException HRException)
            {
                Debug.WriteLine(HRException);
                ReturnObject = new ReturnObject()
                {
                    Content = null, ErrorCode = HRException.HResult, Message = "HttpRequestException : " + HRException.Message
                };
            }
            catch (Newtonsoft.Json.JsonException jEx)
            {
                Debug.WriteLine(jEx);
                ReturnObject = new ReturnObject()
                {
                    Content = null, ErrorCode = jEx.HResult, Message = "JsonException : " + jEx.Message
                };
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
                ReturnObject = new ReturnObject()
                {
                    Content = null, ErrorCode = ex.HResult, Message = "Exception : " + ex.Message
                };
            }
            return(ReturnObject);
        }

        #endregion
    }