Refactors the add book slice and shared media contributor model across the stack

This commit is contained in:
BinaryAlley committed 2026-09-12 12:12:22 -07:00
1 parent 3a2c80b615
commit 9a71a6d32b
61 files changed
+5223 -1384

No files matched your search

@@ -0,0 +1,63 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Common.Models.Core;
using Lumina.Domain.Common.Primitives;
using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.ExternalIdentifiers.MediaContributorBoundedContext.MediaContributorAggregate;
using Lumina.Domain.SharedKernel.Common.Enums.MediaContributors;
using System.Collections.Generic;
using System.Diagnostics;
#endregion
namespace Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.ValueObjects;
/// <summary>
/// Value Object for a media contributor of a book, carrying the role the contributor played.
/// The media contributor is identified only by its Id, duplicated from the Media Contributor bounded context, and the role is
/// the canonical role the contributor played, used as the key of its localized display string.
/// </summary>
[DebuggerDisplay("{Role}")]
public sealed class BookMediaContributor : ValueObject
{
/// <summary>
/// Gets the unique identifier of the media contributor.
/// </summary>
public MediaContributorId ContributorId { get; }
/// <summary>
/// Gets the role the contributor played.
/// </summary>
public MediaContributorRole Role { get; }
/// <summary>
/// Initializes a new instance of the <see cref="BookMediaContributor"/> class.
/// </summary>
/// <param name="contributorId">The unique identifier of the media contributor.</param>
/// <param name="role">The role the contributor played.</param>
private BookMediaContributor(MediaContributorId contributorId, MediaContributorRole role)
{
ContributorId = contributorId;
Role = role;
}
/// <summary>
/// Creates a new instance of the <see cref="BookMediaContributor"/> class.
/// </summary>
/// <param name="contributorId">The unique identifier of the media contributor.</param>
/// <param name="role">The role the contributor played.</param>
/// <returns>
/// An <see cref="Result{TValue}"/> containing either a successfully created <see cref="BookMediaContributor"/>, or an error message.
/// </returns>
public static Result<BookMediaContributor> Create(MediaContributorId contributorId, MediaContributorRole role)
{
return new BookMediaContributor(contributorId, role);
}
/// <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 ContributorId;
yield return Role;
}
}
@@ -0,0 +1,51 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Common.Models.Core;
using System;
using System.Collections.Generic;
using System.Diagnostics;
#endregion
namespace Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.ExternalIdentifiers.MediaContributorBoundedContext.MediaContributorAggregate;
/// <summary>
/// Value Object for the Id of a media contributor, duplicated from the MediaContributor bounded context to keep the cross bounded context references decoupled.
/// </summary>
[DebuggerDisplay("{Value}")]
public sealed class MediaContributorId : EntityId<Guid>
{
/// <summary>
/// Initializes a new instance of the <see cref="MediaContributorId"/> class.
/// </summary>
/// <param name="value">The value representing this object.</param>
private MediaContributorId(Guid value) : base(value)
{
}
/// <summary>
/// Creates a new instance of the <see cref="MediaContributorId"/> class.
/// </summary>
/// <returns>The created <see cref="MediaContributorId"/> instance.</returns>
public static MediaContributorId CreateUnique()
{
return new MediaContributorId(Guid.NewGuid());
}
/// <summary>
/// Creates a new instance of the <see cref="MediaContributorId"/> class, from a pre-existing <paramref name="value"/>.
/// </summary>
/// <param name="value">The value used to create the <see cref="MediaContributorId"/> instance.</param>
/// <returns>The created <see cref="MediaContributorId"/> instance.</returns>
public static MediaContributorId Create(Guid value)
{
return new MediaContributorId(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;
}
}