public IActionResult AddGroupComment(int groupId, [FromBody] GroupCommentViewModel groupComment) { if (groupComment == null) { return(BadRequest("Comment cannot be null.")); } if (groupId < 1) { return(BadRequest("Group could not be found.")); } if (string.IsNullOrEmpty(groupComment.Comment.Comment)) { return(BadRequest("Missing a comment.")); } var groupCommentId = commentService.AddGroupComment(new GroupComment { GroupId = groupId, UserId = groupComment.Comment.UserId, ParentId = groupComment.Comment.ParentId, Comment = groupComment.Comment.Comment, PostDate = DateTime.UtcNow }); if (groupCommentId > 0) { if (groupComment.Comment.ParentId != null) { return(GetAllForGroup(groupId)); } var user = userService.GetById(groupComment.Comment.UserId); groupComment.CurrentComments.Insert(0, new GroupCommentModel { GroupCommentId = groupCommentId, GroupId = groupId, UserId = groupComment.Comment.UserId, ParentId = groupComment.Comment.ParentId, FirstName = user.FirstName, LastName = user.LastName, Comment = groupComment.Comment.Comment, Date = "Just Now", HasChildren = false, Children = new List <GroupCommentModel>() }); } return(Ok(groupComment.CurrentComments)); }