public IActionResult GetPostIDs([FromQuery] PostsGet parameters) { int lastID = parameters.LastID ?? int.MaxValue; var postIDs = (from posts in _context.Posts where posts.Id < lastID orderby posts.Id descending select posts.Id).Take(20).ToList(); return(Ok(postIDs)); }
public ActionResult PostsGet() { using (var db = new DBContext()) { PostsGet PostsGet = new PostsGet { Posts = db.Posts.OrderByDescending(ok => ok.ID).ToList(), Enums = new List <dictionary>() }; foreach (var item in db.LabelTypes.ToList()) { dictionary dic = new dictionary { key = item.Key, value = item.ID, check = false }; PostsGet.Enums.Add(dic); } return(Json(PostsGet, JsonRequestBehavior.AllowGet)); } }
public ActionResult PostsGet() { using (UnitOfWork work = new UnitOfWork()) { PostsGet PostsGet = new PostsGet { Posts = work.PostsRepository.list().OrderByDescending(ok => ok.ID).ToList(), Enums = new List <dictionary>() }; foreach (var item in work.LabelTypesRepository.list()) { dictionary dic = new dictionary { key = item.Key, value = item.ID, check = false }; PostsGet.Enums.Add(dic); } return(Json(PostsGet, JsonRequestBehavior.AllowGet)); } }