private async Task VoteComment(bool up, CommentDTO comment, Image upvote, Image downvote, TextBlock reputation) { ServiceRepository serviceRepository = new ServiceRepository(); upvote.IsTapEnabled = false; downvote.IsTapEnabled = false; upvote.Opacity = 0.4; downvote.Opacity = 0.4; RateCommentPostDTO rip = new RateCommentPostDTO() { commentId = comment.Id, userId = SessionManager.SessionID, score = up }; bool result = await serviceRepository.setVoteComment(rip); if (result) { int factor = 1; if (!up) { factor = -1; } reputation.Text = (int.Parse(reputation.Text) + factor).ToString(); } upvote.IsTapEnabled = true; downvote.IsTapEnabled = true; upvote.Opacity = 1; downvote.Opacity = 1; }
public async Task <bool> setVoteComment(RateCommentPostDTO postDTO) { bool?result = await fetchObject <bool?>(@"/comment/rate/", "POST", postDTO); if (result == null) { return(false); } return((bool)result); }
public IHttpActionResult Rate(RateCommentPostDTO reputationComment) { bool success = true; if (ModelState.IsValid) { try { ReputationCommentEntity repCommentDomain = _DTOAssempler.CreateReputationCommentEntity(reputationComment); ICommentServices commentService = ServiceFactory.getCommentServices(); success = commentService.Rate(repCommentDomain); } catch (Exception e) { return(BadRequest(e.Message)); } } else { return(BadRequest("Neispravni podaci")); } return(Ok(success)); }