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 bool CheckLikeByUserId(int userid, int postid) { return(_context.CheckLikeByUserId(userid, postid)); }