28 lines
No EOL
950 B
C#
28 lines
No EOL
950 B
C#
using JetBrains.Annotations;
|
|
|
|
namespace Femto.Api.Controllers.Posts.Dto;
|
|
|
|
[PublicAPI]
|
|
public record PostDto(
|
|
PostAuthorDto Author,
|
|
Guid PostId,
|
|
string Content,
|
|
IEnumerable<PostMediaDto> Media,
|
|
IEnumerable<PostReactionDto> Reactions,
|
|
DateTimeOffset CreatedAt,
|
|
IEnumerable<string> PossibleReactions,
|
|
IEnumerable<PostCommentDto> 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))
|
|
);
|
|
} |