コード例 #1
0
ファイル: PostsController.cs プロジェクト: grpiccoli/BM
        public async Task <IActionResult> AddPost(NewPostModel model)
        {
            if (model == null)
            {
                return(NotFound());
            }
            var userId = _userManager.GetUserId(User);
            var user   = _userManager.FindByIdAsync(userId).Result;
            var post   = BuildPost(model, user);

            await _postService.Add(post).ConfigureAwait(false);

            await _userService.UpdateUserRating(userId, typeof(Post)).ConfigureAwait(false);

            return(RedirectToAction("Index", "Posts", new { id = post.Id }));
        }
コード例 #2
0
ファイル: RepliesController.cs プロジェクト: grpiccoli/BM
        public async Task <IActionResult> AddReply(PostReplyModel model)
        {
            if (model == null)
            {
                return(NotFound());
            }
            var userId = _userManager.GetUserId(User);
            var user   = await _userManager.FindByIdAsync(userId).ConfigureAwait(false);

            var reply = BuildReply(model, user) as PostReply;

            await _postService.AddReply(reply).ConfigureAwait(false);

            await _userService.UpdateUserRating(userId, typeof(PostReply)).ConfigureAwait(false);

            return(RedirectToAction("Index", "Post", new { id = model.PostId }));
        }