// GET: api/Posts public IEnumerable <Post> Get() { PostsService postsService = new PostsService(); IEnumerable <Post> posts = postsService.GetAllPosts(); return(posts); }
public async Task <IActionResult> Index() { var posts = await _postsService.GetAllPosts(Request.Cookies["token"]); return(View(new HomeViewModel { Posts = posts })); }
public IActionResult Index(int?id) { if (id.HasValue) { return(RedirectToAction("Details", new { id = id.Value })); } var posts = _postsService.GetAllPosts(); var model = new PostsIndexViewModel { Posts = posts }; return(View(model)); }
public ActionResult<Response<List<Post>>> GetAllPosts() { ActionResult result = null; List<Post> postList = null; try { postList = postService.GetAllPosts(); if (postList != null) { result = Ok(postList); } } catch (Exception exception) { throw exception; } return result; }
/// <summary> /// 获取所有论坛的内容 /// </summary> /// <returns></returns> public DataSet GetAllPosts() { return(mss.GetAllPosts()); }