Esempio n. 1
0
        public async Task <ActionResult> Post([FromBody] CircleEventCommentReply model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var circleEventComment = await _repo.GetCircleEventComment(model.CommentId);

            if (circleEventComment == null)
            {
                return(NotFound());
            }
            if (!await this.MatchAppUserWithToken(model.AppUserId) || !await _repo.IsMember((int)model.AppUserId, circleEventComment.CircleId))
            {
                return(Unauthorized());
            }

            model.CircleId = circleEventComment.CircleId;
            // var newTopic = this._mapper.Map<CircleEvent>(model);
            _repo.Add(model);
            await _repo.SaveAll();

            if (circleEventComment.AppUserId == model.AppUserId) //Comment owner
            {
                await _notificationRepo.AddNotification(NotificationEnum.NewCircleEventReplyByOwner, (int)model.AppUserId, model);
            }
            else
            {
                await _notificationRepo.AddNotification(NotificationEnum.NewCircleEventReplyByMember, (int)model.AppUserId, model);
            }
            await _repo.SaveAll();

            return(CreatedAtRoute("GetCircleEventCommentReply", new { id = model.Id }, _mapper.Map <CommentForReturnDto>(model)));
        }
Esempio n. 2
0
        public async Task <ActionResult> Get(int id)
        {
            var circleEventCommentForReturn = _mapper.Map <CircleEventCommentForReturnDto>(await _repo.GetCircleEventComment(id));

            circleEventCommentForReturn.ReplyCount = await _repo.GetCircleEventCommentReplyCount(id);

            return(Ok(circleEventCommentForReturn));
        }
Esempio n. 3
0
        public async Task <ActionResult> GetEventComment(int id, int commentId)
        {
            var comment = await _repo.GetCircleEventComment(commentId);

            var eventCommentForReturn = this._mapper.Map <CircleEventCommentForReturnDto>(comment);

            eventCommentForReturn.ReplyCount = await _repo.GetCircleEventCommentReplyCount(comment.Id);

            return(Ok(eventCommentForReturn));
        }