internal void Map(Comment comment, CommentDetailsModel commentDetailsModel) { commentDetailsModel.CommentId = comment.Id; commentDetailsModel.CreatedOn = comment.CreatedOn; commentDetailsModel.ModifiedOn = comment.ModifiedOn; commentDetailsModel.UserId = comment.UserId; commentDetailsModel.UserName = comment.User.UserName; commentDetailsModel.IssueId = comment.IssueId; commentDetailsModel.UserName = comment.Issue.Name; }
internal CommentDetailsModel BuildCommentDetails(Comment comment, bool includeText = false, bool includeUser = false, bool includeIssue = false) { var commentDetails = Map<CommentDetailsModel>(comment); commentDetails.TextPreview = comment.Text.Length <= 10 ? comment.Text : comment.Text.Substring(0, 10) + "..."; if (includeText) commentDetails.Text = comment.Text; if (includeUser) commentDetails.UserDetails = Service<UserService>().BuildUserDetails(comment.User); if (includeIssue) commentDetails.IssueDetails = Service<IssueService>().BuildIssueDetails(comment.Issue); return commentDetails; }
public int CreateComment(int userId, int issueId, string text) { var currentTime = DateTimeOffset.Now; var comment = new Comment { UserId = userId, IssueId = issueId, Text = text, CreatedOn = currentTime, ModifiedOn = currentTime }; return InsertAndSave(comment).Id; }