mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-01 18:57:24 +00:00
42 lines
1.8 KiB
C#
42 lines
1.8 KiB
C#
#region ========================================================================= USING =====================================================================================
|
|
using ErrorOr;
|
|
using Lumina.Contracts.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary;
|
|
using Lumina.Contracts.Enums.BookLibrary;
|
|
using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.ValueObjects;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
#endregion
|
|
|
|
namespace Lumina.Application.Common.Mapping.MediaLibrary.WrittenContentLibrary.BookLibrary.Common;
|
|
|
|
/// <summary>
|
|
/// Extension methods for converting <see cref="IsbnEntity"/>.
|
|
/// </summary>
|
|
public static class IsbnEntityMapping
|
|
{
|
|
/// <summary>
|
|
/// Converts <paramref name="repositoryEntity"/> to <see cref="Isbn"/>.
|
|
/// </summary>
|
|
/// <param name="repositoryEntity">The repository entity to be converted.</param>
|
|
/// <returns>
|
|
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully converted <see cref="Isbn"/>, or an error message.
|
|
/// </returns>
|
|
public static ErrorOr<Isbn> ToDomainEntity(this IsbnEntity repositoryEntity)
|
|
{
|
|
return Isbn.Create(
|
|
repositoryEntity.Value,
|
|
repositoryEntity.Format ?? IsbnFormat.Isbn13
|
|
);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Converts <paramref name="repositoryEntities"/> to a collection of <see cref="Isbn"/>.
|
|
/// </summary>
|
|
/// <param name="repositoryEntities">The repository entities to be converted.</param>
|
|
/// <returns>The converted domain entities.</returns>
|
|
public static IEnumerable<ErrorOr<Isbn>> ToDomainEntities(this IEnumerable<IsbnEntity> repositoryEntities)
|
|
{
|
|
return repositoryEntities.Select(domainEntity => domainEntity.ToDomainEntity());
|
|
}
|
|
}
|