Esempio n. 1
0
        public IHttpActionResult CreateComment(int pushId, string content)
        {
            var anunt = _anuntService.GetAnuntWithRole(pushId);

            if (User.IsInRole(anunt.Role))
            {
                var dto = new CommentCreateDto()
                {
                    Content = content,
                    Author  = User.Identity.GetUserName(),
                    Created = DateTime.Now,
                    PushId  = pushId
                };

                _commentsService.CreateComment(dto);

                var commentItem = new CommentItemDto()
                {
                    Author  = dto.Author,
                    Content = dto.Content,
                    Created = dto.Created
                };

                _signalRHelper.NotifyCommentsForPush(commentItem, pushId);

                return(Ok());
            }

            return(BadRequest());
        }
        public async Task <bool> AddComment(CommentItemDto commentItemDto)
        {
            var commentItem = _mapper.Map <CommentItem>(commentItemDto);

            commentItem.CreatedAt = DateTime.Now;
            var result = await _unitOfWork.CommentItem.AddComment(commentItem);

            return(result);
        }
        public async Task <IActionResult> Addcomment(CommentItemDto commentItemDto)
        {
            var result = await _actionItemService.AddComment(commentItemDto);

            if (result)
            {
                return(Ok());
            }
            return(BadRequest("Failed to create the action item"));
        }