public async Task <ActionResult> Post([FromBody] CircleTopicCommentReply model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var circleTopicComment = await _repo.GetCircleTopicComment(model.CommentId); if (circleTopicComment == null) { return(NotFound()); } if (!await this.MatchAppUserWithToken(model.AppUserId) || !await _repo.IsMember((int)model.AppUserId, circleTopicComment.CircleId)) { return(Unauthorized()); } model.CircleId = circleTopicComment.CircleId; // var newTopic = this._mapper.Map<CircleTopic>(model); _repo.Add(model); await _repo.SaveAll(); if (circleTopicComment.AppUserId == model.AppUserId) //Comment owner { await _notificationRepo.AddNotification(NotificationEnum.NewCircleCommentReplyByOwner, (int)model.AppUserId, model); } else { await _notificationRepo.AddNotification(NotificationEnum.NewCircleCommentReplyByMember, (int)model.AppUserId, model); } await _repo.SaveAll(); return(CreatedAtRoute("GetCircleTopicCommentReply", new { id = model.Id }, _mapper.Map <CommentForReturnDto>(model))); }
public async Task <ActionResult> Get(int id) { var circleTopicCommentForReturn = _mapper.Map <CircleTopicCommentForReturnDto>(await _repo.GetCircleTopicComment(id)); circleTopicCommentForReturn.ReplyCount = await _repo.GetCircleTopicCommentReplyCount(id); return(Ok(circleTopicCommentForReturn)); }
public async Task <ActionResult> GetTopicComment(int id, int commentId) { var comment = await _repo.GetCircleTopicComment(commentId); var topicsCommentForReturn = this._mapper.Map <CircleTopicCommentForReturnDto>(comment); topicsCommentForReturn.ReplyCount = await _repo.GetCircleTopicCommentReplyCount(comment.Id); return(Ok(topicsCommentForReturn)); }