public async Task <ActionResult> Like(int id) { Domain.Posts.PostsService post = new Domain.Posts.PostsService(); bool suc = await post.Like(id); if (suc) { return(Ok(Result("成功"))); } return(Accepted(Result("失败"))); }
public async Task <ActionResult> GetPostListAsync(int index, int rows, int order) { Paginator pager = new Paginator { Index = index, Rows = rows }; if (index <= 0 || rows <= 0) { pager.List = new List <Posts_Result.PostItem>(); return(BadRequest(Result("参数有误, 请重试", pager))); } Domain.Posts.PostsService postsService = new Domain.Posts.PostsService(); Posts_Result result = await postsService.GetPostsAsync(pager, order); pager.List = result.List; return(Ok(Result("", pager))); }
public async Task <ActionResult> PulishNewPostAsync([FromForm] NewPostInfo model) { if (string.IsNullOrWhiteSpace(model.Author)) { model.Author = "匿名"; } if (string.IsNullOrWhiteSpace(model.Description)) { model.Description = ""; } bool suc; string msg; Domain.Posts.PostsService post = new Domain.Posts.PostsService(); (suc, msg) = await post.PulishNewPostAsync(model); if (suc) { return(Ok(Result("成功"))); } return(Accepted(Result(msg))); }