Пример #1
0
        public async Task AddComment(ForumThreadCommentDTO comment, long userId)
        {
            var entity = Mapper.Map <ForumThreadComment>(comment);

            entity.CreatedById = userId;
            await Unit.ForumThreadComments.Add(entity);

            await Unit.Complete();
        }
Пример #2
0
        public async Task <IActionResult> UpdateComment(long id, [FromBody] ForumThreadCommentDTO model)
        {
            if (!await ForumThreads.CheckIfCommentExists(id))
            {
                return(NotFound());
            }

            await ForumThreads.UpdateComment(id, model);

            return(Ok());
        }
Пример #3
0
        public async Task <IActionResult> AddComment([FromBody] ForumThreadCommentDTO model)
        {
            if (!await ForumThreads.CheckIfExists(model.ThreadId))
            {
                return(NotFound());
            }
            if (model.ParentId.HasValue && !await ForumThreads.CheckIfCommentExists(model.ParentId.Value))
            {
                return(NotFound());
            }

            await ForumThreads.AddComment(model, User.Id());

            return(Ok());
        }