public static LikeViewModel FromLike(Like like) { return(new LikeViewModel { Id = like.Id, User = UserSummaryViewModel.FromUser(like.User) }); }
public static MediaViewModel FromMedia(Media media) => new MediaViewModel { Id = media.Id, MediaType = media.MediaType, MimeType = media.MimeType, FileSize = media.FileSize, Owner = UserSummaryViewModel.FromUser(media.Owner) };
public static RepostViewModel FromRepost(Repost repost) { return(new RepostViewModel { Id = repost.Id, User = UserSummaryViewModel.FromUser(repost.User) }); }
public static PublicationViewModel FromPublication(Publication publication, Guid?userId = null) { return(new PublicationViewModel { Id = publication.Id, CreationDate = publication.CreationDate, SubmissionType = publication.SubmissionType, TextContent = publication.TextContent, MediaId = publication.MediaId == null ? null : publication.MediaId, ReplyPublicationId = publication.ReplyPublicationId, User = UserSummaryViewModel.FromUser(publication.User), RepliesAmount = publication.Replies != null ? publication.Replies.Count : -1, RepostsAmount = publication.Reposts != null ? publication.Reposts.Count : -1, LikesAmount = publication.Likes != null ? publication.Likes.Count : -1, Reposted = userId.HasValue && publication.Reposts.Any(x => x.UserId == userId), Liked = userId.HasValue && publication.Likes.Any(x => x.UserId == userId) }); }