public IHttpActionResult CreateComment(Comment comment) { if (String.IsNullOrEmpty(comment.TopicId)) { return BadRequest("TopicId is missing"); } _commentService.Create(comment); return Ok(comment); }
public void Create(Comment comment) { comment.Id = IdProvider.GenerateId(); comment.CreatedDate = DateTimeOffset.UtcNow; comment.LastModifiedDate = DateTimeOffset.UtcNow; if (!String.IsNullOrEmpty(comment.ParentId)) { Comment parentComment = _dbProvider.GetRecord<Comment>(comment.ParentId); if (parentComment == null) { comment.ParentId = null; } else { comment.AncestorIds = parentComment.AncestorIds; comment.AncestorIds.Add(parentComment.Id); } } _dbProvider.AddRecord(comment); }