public async Task <IActionResult> Create(int id) { //Get post and track for reply var postReply = _postReplyService.GetById(id); //Get the application user that will write the reply for this post var user = await _userManager.FindByNameAsync(User.Identity.Name); var model = new PostReplySupportingBibleVerseModel { AuthorName = User.Identity.Name, AuthorImageUrl = user.ImageUrl, AuthorId = user.Id, AuthorRating = user.Rating, IsAuthorAdmin = User.IsInRole("Admin"), Created = DateTime.Now, PostId = postReply.Post.Id, PostTitle = postReply.Post.Title, PostReplyId = postReply.Id }; return(View(model)); }
//Edit public async Task <IActionResult> Edit(int id) { //Get post and track for reply var postReply = _postReplyService.GetById(id); //Get the application user that will write the reply for this post var user = await _userManager.FindByNameAsync(User.Identity.Name); var model = new PostReplyEditModel { Id = postReply.Id, AuthorName = User.Identity.Name, AuthorImageUrl = user.ImageUrl, AuthorId = user.Id, AuthorRating = user.Rating, IsAuthorAdmin = User.IsInRole("Admin"), Created = postReply.Created, ReplyContent = postReply.Content, EditedCreatedDate = DateTime.Now, VoteCount = postReply.VoteCount, IsEdited = postReply.IsEdited, PostId = postReply.Post.Id, ForumId = postReply.Post.Forum.Id, ForumImageUrl = postReply.Post.Forum.ImageUrl, ForumName = postReply.Post.Forum.Title }; return(View(model)); }
public async Task <IActionResult> Create(int id) { //Get postReplyID and track for reply var postReply = _postReplyService.GetById(id); //Get postID and track for reply var post = _postService.GetById(postReply.Post.Id); //Get the application user that will write the reply for this post var user = await _userManager.FindByNameAsync(User.Identity.Name); var model = new PostReplyReplyModel { PostId = post.Id, PostReplyId = postReply.Id, PostReplyContent = postReply.Content, ReplyOriginalAuthor = postReply.User.UserName, AuthorName = User.Identity.Name, AuthorImageUrl = user.ImageUrl, AuthorId = user.Id, AuthorRating = user.Rating, IsAuthorAdmin = User.IsInRole("Admin"), Created = DateTime.Now }; return(View(model)); }
//Voting public async Task <IActionResult> Vote(int id) { var postReply = _postReplyService.GetById(id); var userId = _userManager.GetUserId(User); var user = await _userManager.FindByIdAsync(userId); var vote = BuildVote(postReply.Id, user); await _postReplyLikeService.Add(vote); return(RedirectToAction("Index", "Post", new { id = postReply.Post.Id })); }
public IActionResult Index(int id) { int userid; var identity = (ClaimsIdentity)User.Identity; IEnumerable <Claim> claims = identity.Claims; try { userid = int.Parse(claims.ElementAt(2).Value); } catch (Exception) { userid = 0; } var post = _post.GetById(id); var user = _user.GetById(post.User.Id); var forum = _forum.GetById(post.Forum.Id); var replies = _postReply.GetById(post.Id); var model = new PostIndexModel { RatedByUser = _post.CheckLikeByUserId(userid, id), Rating = _post.GetRatingById(id), Post = post, User = user, Forum = forum, Replies = replies }; return(View(model)); }
public List <PostReply> GetById(int id) { var returnedList = _context.GetById(id); for (int i = 0; i < returnedList.Count; i++) { returnedList[i].User = _userContext.GetById(returnedList[i].User.Id); } return(returnedList); }