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(); }
public async Task <IActionResult> UpdateComment(long id, [FromBody] ForumThreadCommentDTO model) { if (!await ForumThreads.CheckIfCommentExists(id)) { return(NotFound()); } await ForumThreads.UpdateComment(id, model); return(Ok()); }
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()); }