mirror of
https://github.com/collinbarrett/FilterLists.git
synced 2026-03-11 09:04:27 +00:00
feat(dir): ✨ default license to All Rights Reseerved on FilterList create
This commit is contained in:
parent
9c5cb0cdae
commit
2608baedfd
3 changed files with 26 additions and 3 deletions
|
|
@ -6,6 +6,7 @@ namespace FilterLists.Directory.Domain.Aggregates.FilterLists;
|
|||
public sealed class FilterList : AggregateRoot, IRequireChangeApproval<FilterListChange>
|
||||
{
|
||||
private ICollection<FilterListChange> _changes = new HashSet<FilterListChange>();
|
||||
private int _licenseId;
|
||||
|
||||
private FilterList()
|
||||
{
|
||||
|
|
@ -13,7 +14,7 @@ private FilterList()
|
|||
|
||||
public string Name { get; private init; } = null!;
|
||||
public string? Description { get; private init; }
|
||||
public License? License { get; private init; }
|
||||
public License License { get; private set; } = null!;
|
||||
public Uri? HomeUrl { get; private init; }
|
||||
public Uri? OnionUrl { get; private init; }
|
||||
public Uri? PolicyUrl { get; private init; }
|
||||
|
|
@ -53,7 +54,6 @@ public static FilterList Create(
|
|||
{
|
||||
Name = name,
|
||||
Description = description,
|
||||
License = license,
|
||||
HomeUrl = homeUrl,
|
||||
OnionUrl = onionUrl,
|
||||
PolicyUrl = policyUrl,
|
||||
|
|
@ -65,6 +65,17 @@ public static FilterList Create(
|
|||
DonateUrl = donateUrl,
|
||||
ViewUrls = urls
|
||||
};
|
||||
|
||||
// TODO: resolve temporary inconsistent state between nav prop (default null) and ID field (default 0) between creation and adding to DbContext
|
||||
if (license is not null)
|
||||
{
|
||||
list.License = license;
|
||||
}
|
||||
else
|
||||
{
|
||||
list._licenseId = License.DefaultAllRightsReservedId;
|
||||
}
|
||||
|
||||
list._changes = new HashSet<FilterListChange>(new[] { FilterListChange.Create(list, createReason) });
|
||||
return list;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@ public sealed class License
|
|||
{
|
||||
private License() { }
|
||||
|
||||
public static int DefaultAllRightsReservedId => 5;
|
||||
|
||||
public string Name { get; private init; } = null!;
|
||||
public Uri? Url { get; private init; }
|
||||
public bool PermitsModification { get; private init; }
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
using FilterLists.Directory.Domain.Aggregates.FilterLists;
|
||||
using System.Globalization;
|
||||
using EFCore.NamingConventions.Internal;
|
||||
using FilterLists.Directory.Domain.Aggregates.FilterLists;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
|
|
@ -8,7 +10,15 @@ internal class FilterListTypeConfiguration : IEntityTypeConfiguration<FilterList
|
|||
{
|
||||
public virtual void Configure(EntityTypeBuilder<FilterList> builder)
|
||||
{
|
||||
// TODO: register and resolve INameRewriter
|
||||
var nr = new SnakeCaseNameRewriter(CultureInfo.InvariantCulture);
|
||||
|
||||
builder.Property<int>(nameof(Queries.Entities.FilterList.Id));
|
||||
builder.Property("_licenseId")
|
||||
.HasColumnName(nr.RewriteName(nameof(Queries.Entities.FilterList.LicenseId)));
|
||||
builder.HasOne(f => f.License)
|
||||
.WithMany()
|
||||
.HasForeignKey("_licenseId");
|
||||
builder.Navigation(f => f.Changes)
|
||||
.AutoInclude();
|
||||
builder.Navigation(f => f.ViewUrls)
|
||||
|
|
|
|||
Loading…
Reference in a new issue