Files
T120B165/T120B165-ImgBoard/Dtos/Post/PostDto.cs

29 lines
703 B
C#

using T120B165_ImgBoard.Dtos.Tag;
using File = T120B165_ImgBoard.Models.File;
namespace T120B165_ImgBoard.Dtos.Post;
public record PostDto(
int Id,
string Title,
string Description,
SlimUserDto Author,
List<TagDto> Tags,
string? FileUrl,
DateTime CreatedAt
)
{
public static PostDto FromPost(Models.Post post, string? fileUrl)
{
return new PostDto(
Id: post.Id,
Title: post.Title,
Description: post.Description,
Author: SlimUserDto.FromUser(post.Author),
Tags: post.Tags.Select(TagDto.FromTag).ToList(),
FileUrl: fileUrl,
CreatedAt: post.Created
);
}
}