public IActionResult AddPostToFollow(int postId) { if (_workContext.CurrentCustomer.IsRegistered()) { var post = _postService.GetPost(postId, ""); if (post == null) { return(Ok(new { status = false })); } var postFollow = new Z_Harag_Follow { FollowType = (int)FollowType.Post, PostId = post.Id, CreatedTime = DateTime.Now, UpdatedTime = DateTime.Now, UserId = _workContext.CurrentCustomer.Id }; // check if user exists var exists = _followRepository.IsPostFollowed(post.Id, _workContext.CurrentCustomer.Id); if (exists) { _followRepository.RemovePostFromFollow(post.Id, _workContext.CurrentCustomer.Id); return(Ok(new { status = true, added = false })); } var follow = _followRepository.AddPostToFollow(postFollow); return(Ok(new { status = true, added = true })); } return(Ok(new { status = false })); }