Beispiel #1
0
        public async Task GetServiceArticle(AccessToken token, int id)
        {
            try
            {
                var result = await OkHttpUtils.Instance(token).GetAsyn(string.Format(ApiUtils.ArticleBody, id));

                if (result.IsError)
                {
                    articlesView.GetServiceArticleFail(result.Message);
                }
                else
                {
                    await SQLiteUtils.Instance().QueryArticle(id).ContinueWith(async(response) =>
                    {
                        var article  = response.Result;
                        article.Body = result.Message;
                        await SQLiteUtils.Instance().UpdateArticle(article);
                        articlesView.GetServiceArticleSuccess(article);
                    });
                }
            }
            catch (Exception ex)
            {
                articlesView.GetServiceArticleFail(ex.Message);
            }
        }
        public async Task GetServiceArticle(int slug)
        {
            try
            {
                var article = JsonConvert.DeserializeObject <ArticleModel>(await OkHttpUtils.Instance.GetAsyn(ApiUtils.GetArticle(slug)));
                article.UpdateTime = DateTime.Now;
                await SQLiteUtils.Instance().UpdateArticle(article);

                articleView.GetServiceArticleSuccess(article);
            }
            catch (Exception ex)
            {
                articleView.GetArticleFail(ex.Message);
            }
        }