Exemple #1
0
 public static ViewReplyDto Create(Reply reply)
 {
     return(new ViewReplyDto
     {
         Id = reply.Id,
         Content = reply.Content,
         CreatedAt = reply.CreatedAt,
         User = ViewUserDto.Create(reply.User),
         CommentId = reply.CommentId
     });
 }
Exemple #2
0
 public static TopicResultDto Create(Topic topic)
 {
     return(new TopicResultDto
     {
         Uri = topic.Uri,
         Title = topic.Title,
         Category = ViewCategoryDto.Create(topic.Category),
         User = ViewUserDto.Create(topic.User),
         NumberOfComments = topic.Comments.Count,
         NumberOfViews = topic.Views.Count,
         CreatedAt = DateTime.SpecifyKind(topic.CreatedAt, DateTimeKind.Utc)
     });
 }
Exemple #3
0
 public static ViewCommentDto Create(string userId, Comment comment)
 {
     return(new ViewCommentDto
     {
         Id = comment.Id,
         Content = comment.Content,
         User = ViewUserDto.Create(comment.User),
         CreatedAt = comment.CreatedAt,
         NumberOfUpVotes = comment.Votes.Count(c => c.IsUp),
         NumberOfDownVotes = comment.Votes.Count(c => !c.IsUp),
         IsUpVoted = userId != null?comment.Votes.FirstOrDefault(c => c.UserId.Equals(userId))?.IsUp : null,
         Replies = comment.Replies.Select(ViewReplyDto.Create)
     });
 }
Exemple #4
0
 public static NotificationDto Create(Notification notification, ApplicationUser sender, Topic topic, Comment comment = null)
 {
     return(new NotificationDto
     {
         Id = notification.Id,
         Type = notification.Type,
         Sender = ViewUserDto.Create(sender),
         CreatedAt = notification.CreatedAt,
         Uri = topic.Uri,
         Title = notification.CommentId != null ? "Comment: " + comment?.Content : "Topic: " + topic.Title,
         TopicId = notification.TopicId ?? default,
         IsRead = notification.IsRead,
         CommentId = notification.CommentId,
         NewId = notification.NewId
     });
Exemple #5
0
 public static ViewTopicDto Create(string userId, Topic topic, bool isBookmarked)
 {
     return(new ViewTopicDto
     {
         Id = topic.Id,
         Title = topic.Title,
         Content = topic.Content,
         Uri = topic.Uri,
         Category = ViewCategoryDto.Create(topic.Category),
         User = ViewUserDto.Create(topic.User),
         CreatedAt = topic.CreatedAt,
         NumberOfUpVotes = topic.Votes.Count(c => c.IsUp),
         NumberOfDownVotes = topic.Votes.Count(c => !c.IsUp),
         IsUpVoted = userId != null?topic.Votes.FirstOrDefault(c => c.UserId.Equals(userId))?.IsUp : null,
         IsBookmarked = isBookmarked,
         Comments = topic.Comments.Select(c => ViewCommentDto.Create(userId, c))
     });
 }