public async Task OnGet(int id, string token) { if (id > 0 && !string.IsNullOrEmpty(token)) { var result = await _httpHelper.GetAsync <ApiResult <ArticleOutput> >($"article/detail?id={id}", token); if (result != null && result.Success && result.StatusCode == 200) { articleOutput = result.Data; } } }
public IHttpActionResult GetArticle(string id) { try { var item = Context.Database.GetItem(ID.Parse(id)); if (!item.IsOnCurrentSite()) { throw new ArgumentException($"Article {id} is not found"); } var output = new ArticleOutput(Constants.ApiStatus.Success, new Article(item)); return(this.JsonResult <ArticleOutput>(output)); } catch (Exception ex) { Log.Error($":GetArticle({id}). Error message: {ex.Message}", ex, this); var error = new JsonOutput(Constants.ApiStatus.Fail, ex.Message); return(this.JsonResult <JsonOutput>(error)); } }