Beispiel #1
0
 public ReplyViewModel(Reply reply, ApplicationUser user = null)
 {
     Id           = reply.Id;
     Content      = reply.Content;
     LastActivity = Activity.FromDates(reply.DateCreated, reply.DateEdited);
     Author       = reply.Author;
     Likes        = reply.Likes;
     LikeCount    = reply.Likes is null ? 0 : reply.Likes.Count;
     if (user is not null)
     {
         Liked = Likes.FirstOrDefault(l => l.UserId == user.Id) is not null;
     }
 }
 public PostViewModel(Post post, ApplicationUser user = null)
 {
     Id           = post.Id;
     Title        = post.Title;
     Content      = post.Content;
     LastActivity = Activity.FromDates(post.DateCreated, post.DateEdited);
     Author       = post.Author;
     Category     = post.Category;
     FillReplies(post.Replies, user);
     Likes     = post.Likes;
     LikeCount = post.Likes is null ? 0 : post.Likes.Count;
     if (user is not null)
     {
         Liked = Likes.FirstOrDefault(l => l.UserId == user.Id) is not null;
     }
 }