示例#1
0
        public async Task <IActionResult> CreateAsync(CreatePostDto newPost)
        {
            var post = await _postService.AddNewPostAsync(newPost);

            return(Created($"api/posts/{post.Id}", new Response <PostDto>(post)));
        }
示例#2
0
 public IActionResult AddPost(string postText)
 {
     _postService.AddNewPostAsync(User.Identity.Name, postText);
     return(RedirectToAction("Index", "Home"));
 }
示例#3
0
        public async Task <IActionResult> Create(CreatePostDto newPost)
        {
            var post = await _postService.AddNewPostAsync(newPost, User.FindFirstValue(ClaimTypes.NameIdentifier));

            return(Created($"api/posts/{post.Id}", new Response <PostDto>(post)));
        }
示例#4
0
 public IActionResult AfterAddNewPost(Post post)
 {
     postService.AddNewPostAsync(post);
     return(RedirectToAction(nameof(Index), "Home", postService.RankPosts(applicationContext.Posts.ToList())));
 }