Almost finish implementing client side
This commit is contained in:
@@ -1,13 +1,14 @@
|
||||
namespace T120B165_ImgBoard.Dtos.Comment;
|
||||
|
||||
public record CommentDto(int Id, string Text, SlimUserDto Author)
|
||||
public record CommentDto(int Id, string Text, SlimUserDto Author, DateTime CreatedAt)
|
||||
{
|
||||
public static CommentDto FromComment(Models.Comment comment)
|
||||
{
|
||||
return new CommentDto(
|
||||
Id: comment.Id,
|
||||
Text: comment.Text,
|
||||
Author: SlimUserDto.FromUser(comment.Author)
|
||||
Author: SlimUserDto.FromUser(comment.Author),
|
||||
CreatedAt: comment.Created
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using T120B165_ImgBoard.Dtos.Tag;
|
||||
using File = T120B165_ImgBoard.Models.File;
|
||||
|
||||
namespace T120B165_ImgBoard.Dtos.Post;
|
||||
@@ -7,8 +8,9 @@ public record PostDto(
|
||||
string Title,
|
||||
string Description,
|
||||
SlimUserDto Author,
|
||||
List<Models.Tag> Tags,
|
||||
string? FileUrl
|
||||
List<TagDto> Tags,
|
||||
string? FileUrl,
|
||||
DateTime CreatedAt
|
||||
)
|
||||
{
|
||||
public static PostDto FromPost(Models.Post post, string? fileUrl)
|
||||
@@ -18,8 +20,9 @@ public record PostDto(
|
||||
Title: post.Title,
|
||||
Description: post.Description,
|
||||
Author: SlimUserDto.FromUser(post.Author),
|
||||
Tags: post.Tags,
|
||||
FileUrl: fileUrl
|
||||
Tags: post.Tags.Select(TagDto.FromTag).ToList(),
|
||||
FileUrl: fileUrl,
|
||||
CreatedAt: post.Created
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ public record CreateTagDto(
|
||||
TagType Type,
|
||||
[Required]
|
||||
[StringLength(64)]
|
||||
[RegularExpression(@"^[a-zA-Z0-9-]+$", ErrorMessage = "The name must only contain alphanumeric characters and hyphens.")]
|
||||
string Name
|
||||
);
|
||||
|
||||
|
||||
14
T120B165-ImgBoard/Dtos/Tag/TagDto.cs
Normal file
14
T120B165-ImgBoard/Dtos/Tag/TagDto.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using T120B165_ImgBoard.Models;
|
||||
|
||||
namespace T120B165_ImgBoard.Dtos.Tag;
|
||||
|
||||
public record TagDto(string Name, TagType Type)
|
||||
{
|
||||
public static TagDto FromTag(Models.Tag tag)
|
||||
{
|
||||
return new TagDto(
|
||||
Name: tag.Name,
|
||||
Type: tag.Type
|
||||
);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user