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 }); }
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) }); }
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) }); }
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 });
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)) }); }