public void Add(CommentLike commentLike) { using (var svc = new ServiceProxyHelper<ICommentLikesService>("CommentLikesService")) { svc.Proxy.Add(commentLike); } }
public void Add(int commentId, string username, string authenticationToken) { using (var svc = new HttpClientHelper()) { var commentLikeDummy = new CommentLike(); svc.Post(Constants.BlogRestUrl, string.Format("comments/likes?commentId={0}&username={1}", commentId, username), commentLikeDummy, authenticationToken); } }
public CommentLike Add(CommentLike commentLike) { try { var tmpCommentLike = _commentLikeRepository.Find(a => a.CommentId == commentLike.CommentId && a.UserId == commentLike.UserId, false); if (tmpCommentLike.Count > 0) { _commentLikeRepository.Delete(tmpCommentLike.FirstOrDefault()); return null; } return CommentLikeMapper.ToDto(_commentLikeRepository.Add(CommentLikeMapper.ToEntity(commentLike))); } catch (Exception ex) { throw new BlogException(ex.Message, ex.InnerException); } }
public void Post([FromUri]int commentId, string username) { try { var user = _user.GetByUserName(username); var loggedUser = _user.GetByUserName(User.Identity.Name); if (loggedUser.Id != user.Id) throw new HttpResponseException(HttpStatusCode.Forbidden); var commentLike = new CommentLike { CommentId = commentId, UserId = user.Id }; _service.Add(commentLike); } catch (Exception ex) { _errorSignaler.SignalFromCurrentContext(ex); } }
public void Add(CommentLike commentLike) { var result = _commentLikesLogic.Add(commentLike); if (result != null && result.Error != null) throw new Exception(result.Error.Message); var parentComment = _commentsLogic.Get(commentLike.CommentId); if (parentComment == null) throw new Exception(string.Format( "Failed to like comment {0} due to error in fetching comment", commentLike.CommentId)); var commentLikes = _commentLikesLogic.Get(commentLike.CommentId); if (commentLikes == null) throw new Exception(string.Format( "Failed to like comment {0} due to error in fetching likes in comment", commentLike.CommentId)); var commentLikesUpdate = new CommentLikesUpdate { CommentId = commentLike.CommentId, PostId = parentComment.PostId, CommentLikes = commentLikes, ClientFunction = Constants.SocketClientFunctions.CommentLikesUpdate.ToString() }; _redisService.Publish(commentLikesUpdate); }