using JetBrains.Annotations; namespace Femto.Api.Controllers.Posts.Dto; [PublicAPI] public record PostDto( PostAuthorDto Author, Guid PostId, string Content, IEnumerable Media, IEnumerable Reactions, DateTimeOffset CreatedAt, IEnumerable PossibleReactions, IEnumerable Comments ) { public static PostDto FromModel(Modules.Blog.Application.Queries.GetPosts.Dto.PostDto post) => new( new PostAuthorDto(post.Author.AuthorId, post.Author.Username), post.PostId, post.Text, post.Media.Select(m => new PostMediaDto(m.Url, m.Width, m.Height)), post.Reactions.Select(r => new PostReactionDto(r.Emoji, r.AuthorName, r.ReactedOn)), post.CreatedAt, post.PossibleReactions, post.Comments.Select(c => new PostCommentDto(c.Author, c.Content, c.PostedOn)) ); }