示例#1
0
        public async Task <IHttpActionResult> GetStats(int id)
        {
            if (Request.Headers.Referrer != null && Request.Headers.Referrer.ToString().Contains(Config.SERVER))
            {
                var article = await db.Articles.Where(c => c.Id == id).Include(c => c.Stats).FirstOrDefaultAsync();

                var stats = article.Stats.ToList();
                stats.Sort((x, y) => DateTime.Compare(x.Date, y.Date));
                return(Ok(JsonHelper.ConvertArticleStats(stats)));
            }
            return(BadRequest());
        }