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}")); }
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)); }