示例#1
0
        public async Task <IActionResult> Create(CommentsCreateModel model)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.View(model));
            }
            var parentUserProfile = this.postsService.GetUserByPostId(model.PostId);

            await this.commentsService.CreateAsync(model.PostId, model.UserId, model.Content);

            return(this.Redirect($"/Profiles/Profile?id={parentUserProfile}#{model.PostId}"));
        }
示例#2
0
        public IActionResult Create(string id)
        {
            var userId = this.userManager.GetUserId(this.User);

            if (!this.postsService.GetFirstNameById(userId))
            {
                return(this.Redirect("/Profiles/Details"));
            }
            var viewModel = new CommentsCreateModel
            {
                PostId       = this.postsService.GetPostById(id),
                UserId       = userId,
                UserFullName = this.postsService.GetCreatorOfPostByCommentId(id),
            };

            return(this.View(viewModel));
        }