示例#1
0
        // GET: api/Posts
        public IEnumerable <Post> Get()
        {
            PostsService       postsService = new PostsService();
            IEnumerable <Post> posts        = postsService.GetAllPosts();

            return(posts);
        }
示例#2
0
        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;
        }
示例#5
0
 /// <summary>
 /// 获取所有论坛的内容
 /// </summary>
 /// <returns></returns>
 public DataSet GetAllPosts()
 {
     return(mss.GetAllPosts());
 }