Il reste a faire la migration! Je ne suis pas capable.

This commit is contained in:
PascalMarchesseault
2024-11-11 11:15:35 -05:00
parent b9edb80e70
commit 4176ec5170
8 changed files with 24 additions and 2 deletions

View File

@@ -11,8 +11,11 @@ public class Content
public Guid? DeletedBy { get; set; }
public DateTimeOffset? DeletedAt { get; set; }
[MaxLength(128)] public required string Title { get; set; }
[MaxLength(512)]public string? ThumbnailUrl { get; init; }
[MaxLength(2048)] public string Description { get; set; } = "";
[MaxLength(2048)] public string? HtmlFileUrl { get; set; } = "";
public IList<ContentReaction> Reactions { get; set; } = new List<ContentReaction>();
public string[]? Urls { get; init; }
public string[]? Urls { get; init; }
}

View File

@@ -30,6 +30,11 @@ public class ContentDbContext(
.OwnsMany(c => c.Reactions)
.ToTable("Reactions");
modelBuilder
.Entity<Content>()
.Property(c => c.ThumbnailUrl);
modelBuilder
.Entity<Creator>()
.OwnsOne<Socials>(x => x.Socials)
@@ -44,5 +49,7 @@ public class ContentDbContext(
.Entity<Creator>()
.OwnsOne<Images>(x => x.Images)
.ToTable(nameof(Images));
}
}

View File

@@ -14,8 +14,10 @@ public record PostContentRequest(
string Title,
string Description,
IFormFileCollection? Files,
string ThumbnailUrl,
string[]? ExternalUrls);
[PublicAPI]
public sealed class PostContentRequestValidator : Validator<PostContentRequest>
{
@@ -40,6 +42,8 @@ public sealed class PostContentRequestValidator : Validator<PostContentRequest>
RuleForEach(r => r.ExternalUrls)
.NotEmpty().WithMessage("External URL cannot be empty")
.Must(url => Uri.IsWellFormedUriString(url, UriKind.Absolute)).WithMessage("External URL is not valid");
}
}
@@ -102,7 +106,9 @@ public sealed class PostContent(
CreatedBy = User.GetUserId(),
Title = req.Title,
Description = req.Description,
Urls = urls.IsEmpty ? null : urls.ToArray()
Urls = urls.IsEmpty ? null : urls.ToArray(),
ThumbnailUrl = req.ThumbnailUrl,
},
ct);
@@ -122,6 +128,7 @@ public sealed class PostContent(
Title = c.Title,
Description = c.Description,
Urls = c.Urls,
ThumbnailUrl = c.ThumbnailUrl,
})
.SingleOrDefaultAsync(
c => c.Id == req.Id,

View File

@@ -75,6 +75,7 @@ public sealed class PostContentHtml(
Title = c.Title,
Description = c.Description,
Urls = c.Urls,
ThumbnailUrl = c.ThumbnailUrl,
HtmlFileUrl = htmlFileUrl
})
.SingleOrDefaultAsync(

View File

@@ -40,6 +40,7 @@ public class GetContent(
Title = c.Title,
Description = c.Description,
Urls = c.Urls,
ThumbnailUrl = c.ThumbnailUrl,
HtmlFileUrl = c.HtmlFileUrl ?? "",
Reactions = c.Reactions.Select(x => new ReactionModel
{

View File

@@ -51,6 +51,7 @@ public class GetContentsByCreatorHandler(
Title = c.Title,
Description = c.Description,
Urls = c.Urls,
ThumbnailUrl = c.ThumbnailUrl,
HtmlFileUrl = c.HtmlFileUrl ?? "",
Reactions = c.Reactions.Select(x => new ReactionModel
{

View File

@@ -50,6 +50,7 @@ public class GetFeaturedContentsHandler(
Title = c.Title,
Description = c.Description,
Urls = c.Urls,
ThumbnailUrl = c.ThumbnailUrl,
Reactions = c.Reactions.Select(x => new ReactionModel
{
Reaction = x.Reaction.FromEnum(),

View File

@@ -14,5 +14,6 @@ public class ContentModel
public required string Description { get; init; }
public string HtmlFileUrl { get; init; } = "";
public required string[]? Urls { get; init; }
public string? ThumbnailUrl { get; init; }
public IList<ReactionModel>? Reactions { get; set; } = new List<ReactionModel>();
}