mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 06:11:10 +00:00
Refactors the book, artist, and album slices across the stack
This commit is contained in:
1 parent
8aaf9fe64e
commit
ea6eb9f796
439 files changed
+28235
-3156
No files matched your search
+16
-18
@@ -1,7 +1,6 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Common.Models.Core;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.MediaContributorBoundedContext.MediaContributorAggregate.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.Entities;
|
||||
using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.ExternalIdentifiers.LibraryManagementBoundedContext.LibraryAggregate;
|
||||
@@ -19,7 +18,7 @@ namespace Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext
|
||||
[DebuggerDisplay("Id: {Id} Title: {Title}")]
|
||||
public sealed class Book : AggregateRoot<BookId>
|
||||
{
|
||||
private readonly List<MediaContributorId> _contributors;
|
||||
private readonly HashSet<BookMediaContributor> _contributors;
|
||||
private readonly List<BookRating> _ratings;
|
||||
private readonly List<Isbn> _isbns;
|
||||
|
||||
@@ -109,12 +108,10 @@ public sealed class Book : AggregateRoot<BookId>
|
||||
public IReadOnlyCollection<Isbn> ISBNs => _isbns.AsReadOnly();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the list of objects representing the unique identifiers of the media contributors (actors, directors, etc) starring in this book.
|
||||
/// Gets the list of media contributors that contributed to this book, each carrying the role
|
||||
/// the contributor played, used as the key of its localized display string.
|
||||
/// </summary>
|
||||
public IReadOnlyCollection<MediaContributorId> Contributors => _contributors.AsReadOnly();
|
||||
// TODO: the roles of the media contributors currently live only in the persistence layer (BookContributorEntity), and are lost
|
||||
// at the domain level. To keep consistency with the Music aggregate, which models its credits as a MediaContributorCredit value
|
||||
// object carrying both the contributor and the role, the roles should be moved into the Book aggregate as well.
|
||||
public IReadOnlyCollection<BookMediaContributor> Contributors => _contributors.AsReadOnly();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the list of ratings for this book.
|
||||
@@ -144,7 +141,7 @@ public sealed class Book : AggregateRoot<BookId>
|
||||
/// <param name="createdOnUtc">The date and time when the entity was created.</param>
|
||||
/// <param name="updatedOnUtc">The date and time when the entity was last updated.</param>
|
||||
/// <param name="isbns">The list of ISBNs of the book.</param>
|
||||
/// <param name="contributors">The list of objects representing the unique identifiers of the media contributors of the book.</param>
|
||||
/// <param name="contributors">The list of media contributors of the book, each carrying the role the contributor played.</param>
|
||||
/// <param name="ratings">The list of ratings for the book.</param>
|
||||
private Book(
|
||||
BookId id,
|
||||
@@ -167,7 +164,7 @@ public sealed class Book : AggregateRoot<BookId>
|
||||
DateTime createdOnUtc,
|
||||
Optional<DateTime> updatedOnUtc,
|
||||
List<Isbn> isbns,
|
||||
List<MediaContributorId> contributors,
|
||||
IEnumerable<BookMediaContributor> contributors,
|
||||
List<BookRating> ratings) : base(id)
|
||||
{
|
||||
Id = id;
|
||||
@@ -190,7 +187,7 @@ public sealed class Book : AggregateRoot<BookId>
|
||||
CreatedOnUtc = createdOnUtc;
|
||||
UpdatedOnUtc = updatedOnUtc.HasValue ? updatedOnUtc.Value : null;
|
||||
_isbns = isbns;
|
||||
_contributors = contributors;
|
||||
_contributors = [.. contributors];
|
||||
_ratings = ratings;
|
||||
}
|
||||
|
||||
@@ -214,7 +211,7 @@ public sealed class Book : AggregateRoot<BookId>
|
||||
/// <param name="barnesAndNobleId">The optional Barnes & Noble ID of the book.</param>
|
||||
/// <param name="appleBooksId">The optional Apple Books ID of the book.</param>
|
||||
/// <param name="isbns">The list of ISBNs of the book.</param>
|
||||
/// <param name="contributors">The list of objects representing the unique identifiers of the media contributors of the book.</param>
|
||||
/// <param name="contributors">The list of media contributors of the book, each carrying the role the contributor played.</param>
|
||||
/// <param name="ratings">The list of ratings for the book.</param>
|
||||
/// <returns>
|
||||
/// An <see cref="Result{TValue}"/> containing either a successfully created <see cref="Book"/>, or an error message.
|
||||
@@ -237,7 +234,7 @@ public sealed class Book : AggregateRoot<BookId>
|
||||
Optional<string> barnesAndNobleId,
|
||||
Optional<string> appleBooksId,
|
||||
List<Isbn> isbns,
|
||||
List<MediaContributorId> contributors,
|
||||
IEnumerable<BookMediaContributor> contributors,
|
||||
List<BookRating> ratings)
|
||||
{
|
||||
// TODO: enforce invariants
|
||||
@@ -290,7 +287,7 @@ public sealed class Book : AggregateRoot<BookId>
|
||||
/// <param name="createdOnUtc">The date and time when the entity was created.</param>
|
||||
/// <param name="updatedOnUtc">The date and time when the entity was last updated.</param>
|
||||
/// <param name="isbns">The list of ISBNs of the book.</param>
|
||||
/// <param name="contributors">The list of objects representing the unique identifiers of the media contributors of the book.</param>
|
||||
/// <param name="contributors">The list of media contributors of the book, each carrying the role the contributor played.</param>
|
||||
/// <param name="ratings">The list of ratings for the book.</param>
|
||||
/// <returns>
|
||||
/// An <see cref="Result{TValue}"/> containing either a successfully created <see cref="Book"/>, or an error message.
|
||||
@@ -316,7 +313,7 @@ public sealed class Book : AggregateRoot<BookId>
|
||||
DateTime createdOnUtc,
|
||||
Optional<DateTime> updatedOnUtc,
|
||||
List<Isbn> isbns,
|
||||
List<MediaContributorId> contributors,
|
||||
IEnumerable<BookMediaContributor> contributors,
|
||||
List<BookRating> ratings)
|
||||
{
|
||||
// TODO: enforce invariants
|
||||
@@ -347,14 +344,15 @@ public sealed class Book : AggregateRoot<BookId>
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Replaces the media contributors of the book with the provided <paramref name="contributors"/>, identified by their unique identifiers.
|
||||
/// Replaces the media contributors of the book with the provided <paramref name="contributors"/>, each carrying
|
||||
/// the media contributor and the role the contributor played in the book.
|
||||
/// </summary>
|
||||
/// <param name="contributors">The unique identifiers of the media contributors of the book.</param>
|
||||
public void UpdateContributors(IReadOnlyCollection<MediaContributorId> contributors)
|
||||
/// <param name="contributors">The media contributors of the book.</param>
|
||||
public void UpdateContributors(IReadOnlyCollection<BookMediaContributor> contributors)
|
||||
{
|
||||
// replace the contents of the collection in place, preserving the readonly reference invariants of the aggregate
|
||||
_contributors.Clear();
|
||||
_contributors.AddRange(contributors);
|
||||
_contributors.UnionWith(contributors);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
-17
@@ -1,17 +0,0 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.Services;
|
||||
|
||||
/// <summary>
|
||||
/// Service for managing book libraries.
|
||||
/// </summary>
|
||||
public sealed class BookLibraryService : IBookLibraryService
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the collection of books in the library.
|
||||
/// </summary>
|
||||
public ICollection<Book> Books => throw new NotImplementedException();
|
||||
}
|
||||
-25
@@ -1,25 +0,0 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System.Collections.Generic;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.Services;
|
||||
|
||||
/// <summary>
|
||||
/// Interface for the service for managing book libraries.
|
||||
/// </summary>
|
||||
public interface IBookLibraryService
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the collection of books in the library.
|
||||
/// </summary>
|
||||
ICollection<Book> Books { get; }
|
||||
|
||||
// ICollection<BookSeries> Series { get; }
|
||||
|
||||
// void AddBook(Book book);
|
||||
// void RemoveBook(Guid bookId);
|
||||
// void AddSeries(BookSeries series);
|
||||
// void RemoveSeries(Guid seriesId);
|
||||
// Book GetBook(Guid bookId);
|
||||
// BookSeries GetSeries(Guid seriesId);
|
||||
}
|
||||
-54
@@ -1,54 +0,0 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Common.Models.Core;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Value Object for the Id of a book library.
|
||||
/// </summary>
|
||||
[DebuggerDisplay("{Value}")]
|
||||
public sealed class BookLibraryId : EntityId<Guid> // TODO: to be removed
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="BookLibraryId"/> class.
|
||||
/// </summary>
|
||||
/// <param name="value">The value representing this object.</param>
|
||||
private BookLibraryId(Guid value) : base(value)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <see cref="BookLibraryId"/> class.
|
||||
/// </summary>
|
||||
/// <returns>The created <see cref="BookLibraryId"/> instance.</returns>
|
||||
public static Result<BookLibraryId> CreateUnique()
|
||||
{
|
||||
// TODO: enforce invariants
|
||||
return new BookLibraryId(Guid.NewGuid());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <see cref="BookLibraryId"/> class, from a pre-existing <paramref name="value"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">The value used to create the <see cref="BookLibraryId"/> instance.</param>
|
||||
/// <returns>The created <see cref="BookLibraryId"/> instance.</returns>
|
||||
public static Result<BookLibraryId> Create(Guid value)
|
||||
{
|
||||
// TODO: enforce invariants
|
||||
return new BookLibraryId(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the list of items that define equality of the object.
|
||||
/// </summary>
|
||||
/// <returns>A list of items defining the equality.</returns>
|
||||
public override IEnumerable<object> GetEqualityComponents()
|
||||
{
|
||||
yield return Value;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user