Exemple #1
0
        public async Task <IActionResult> Newnews([FromBody] Pagee page)
        {
            List <Post> posts = null;

            //if (!cache.TryGetValue("news", out posts))
            //{
            posts = await db.Posts.OrderByDescending(x => x.Id).Take((page.PageSize) * 10).Skip((page.PageSize - 1) * 10).ToListAsync();

            //    cache.Set("news", posts, new MemoryCacheEntryOptions().SetAbsoluteExpiration(TimeSpan.FromHours(12)));
            //}


            return(Json(posts));
        }
Exemple #2
0
        public async Task <IActionResult> News([FromBody] Pagee page)
        {
            var news = await db.Posts.OrderByDescending(x => x.Id).ToListAsync();

            return(Json(news));
        }