mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 01:11:10 +00:00
Implements first stage library management system
This commit is contained in:
1 parent
5e0f94cd82
commit
36352ea9e8
291 files changed
+3733
-1384
No files matched your search
@@ -1,7 +1,7 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DataAccess.Repositories.Common.Actions;
|
||||
using Lumina.Application.Common.DataAccess.Repositories.Common.Base;
|
||||
using Lumina.Contracts.Entities.WrittenContentLibrary.BookLibrary;
|
||||
using Lumina.Contracts.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.DataAccess.Repositories.Books;
|
||||
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DataAccess.Repositories.Common.Actions;
|
||||
using Lumina.Application.Common.DataAccess.Repositories.Common.Base;
|
||||
using Lumina.Contracts.Entities.MediaLibrary.Management;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.DataAccess.Repositories.MediaLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Interface for the repository for media libraries.
|
||||
/// </summary>
|
||||
public interface ILibraryRepository : IRepository<LibraryEntity>,
|
||||
IInsertRepositoryAction<LibraryEntity>
|
||||
{
|
||||
}
|
||||
+8
-8
@@ -11,14 +11,14 @@ namespace Lumina.Application.Common.Mapping.Common.Metadata;
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="GenreEntity"/>.
|
||||
/// </summary>
|
||||
public static class GenreModelMapping
|
||||
public static class GenreEntityMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="repositoryEntity"/> to <see cref="GenreEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="repositoryEntity">The repository model to be converted.</param>
|
||||
/// <returns>The converted domain model.</returns>
|
||||
public static ErrorOr<Genre> ToDomainModel(this GenreEntity repositoryEntity)
|
||||
/// <param name="repositoryEntity">The repository entity to be converted.</param>
|
||||
/// <returns>The converted domain entity.</returns>
|
||||
public static ErrorOr<Genre> ToDomainEntity(this GenreEntity repositoryEntity)
|
||||
{
|
||||
return Genre.Create(
|
||||
repositoryEntity.Name
|
||||
@@ -28,10 +28,10 @@ public static class GenreModelMapping
|
||||
/// <summary>
|
||||
/// Converts <paramref name="repositoryEntities"/> to a collection of <see cref="Genre"/>.
|
||||
/// </summary>
|
||||
/// <param name="repositoryEntities">The repository models to be converted.</param>
|
||||
/// <returns>The converted domain models.</returns>
|
||||
public static IEnumerable<ErrorOr<Genre>> ToDomainModels(this IEnumerable<GenreEntity> repositoryEntities)
|
||||
/// <param name="repositoryEntities">The repository entities to be converted.</param>
|
||||
/// <returns>The converted domain entities.</returns>
|
||||
public static IEnumerable<ErrorOr<Genre>> ToDomainEntities(this IEnumerable<GenreEntity> repositoryEntities)
|
||||
{
|
||||
return repositoryEntities.Select(repositoryEntity => repositoryEntity.ToDomainModel());
|
||||
return repositoryEntities.Select(repositoryEntity => repositoryEntity.ToDomainEntity());
|
||||
}
|
||||
}
|
||||
@@ -13,24 +13,24 @@ namespace Lumina.Application.Common.Mapping.Common.Metadata;
|
||||
public static class GenreMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="domainModel"/> to <see cref="GenreEntity"/>.
|
||||
/// Converts <paramref name="domainEntity"/> to <see cref="GenreEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="domainModel">The domain model to be converted.</param>
|
||||
/// <param name="domainEntity">The domain entity to be converted.</param>
|
||||
/// <returns>The converted repository entity.</returns>
|
||||
public static GenreEntity ToRepositoryEntity(this Genre domainModel)
|
||||
public static GenreEntity ToRepositoryEntity(this Genre domainEntity)
|
||||
{
|
||||
return new GenreEntity(
|
||||
domainModel.Name
|
||||
domainEntity.Name
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts <paramref name="domainModels"/> to a collection of <see cref="GenreEntity"/>.
|
||||
/// Converts <paramref name="domainEntities"/> to a collection of <see cref="GenreEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="domainModels">The domain models to be converted.</param>
|
||||
/// <param name="domainEntities">The domain entities to be converted.</param>
|
||||
/// <returns>The converted repository entities.</returns>
|
||||
public static IEnumerable<GenreEntity> ToRepositoryEntities(this IEnumerable<Genre> domainModels)
|
||||
public static IEnumerable<GenreEntity> ToRepositoryEntities(this IEnumerable<Genre> domainEntities)
|
||||
{
|
||||
return domainModels.Select(domainModel => domainModel.ToRepositoryEntity());
|
||||
return domainEntities.Select(domainEntity => domainEntity.ToRepositoryEntity());
|
||||
}
|
||||
}
|
||||
+6
-6
@@ -11,14 +11,14 @@ namespace Lumina.Application.Common.Mapping.Common.Metadata;
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="TagEntity"/>.
|
||||
/// </summary>
|
||||
public static class TagModelMapping
|
||||
public static class TagEntityMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="repositoryEntity"/> to <see cref="Tag"/>.
|
||||
/// </summary>
|
||||
/// <param name="repositoryEntity">The repository entity to be converted.</param>
|
||||
/// <returns>The converted domain model.</returns>
|
||||
public static ErrorOr<Tag> ToDomainModel(this TagEntity repositoryEntity)
|
||||
/// <returns>The converted domain entity.</returns>
|
||||
public static ErrorOr<Tag> ToDomainEntity(this TagEntity repositoryEntity)
|
||||
{
|
||||
return Tag.Create(
|
||||
repositoryEntity.Name
|
||||
@@ -29,9 +29,9 @@ public static class TagModelMapping
|
||||
/// Converts <paramref name="repositoryEntities"/> to a collection of <see cref="Tag"/>.
|
||||
/// </summary>
|
||||
/// <param name="repositoryEntities">The repository entities to be converted.</param>
|
||||
/// <returns>The converted domain models.</returns>
|
||||
public static IEnumerable<ErrorOr<Tag>> ToDomainModels(this IEnumerable<TagEntity> repositoryEntities)
|
||||
/// <returns>The converted domain entities.</returns>
|
||||
public static IEnumerable<ErrorOr<Tag>> ToDomainEntities(this IEnumerable<TagEntity> repositoryEntities)
|
||||
{
|
||||
return repositoryEntities.Select(domainModel => domainModel.ToDomainModel());
|
||||
return repositoryEntities.Select(domainEntity => domainEntity.ToDomainEntity());
|
||||
}
|
||||
}
|
||||
@@ -13,24 +13,24 @@ namespace Lumina.Application.Common.Mapping.Common.Metadata;
|
||||
public static class TagMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="domainModel"/> to <see cref="TagEntity"/>.
|
||||
/// Converts <paramref name="domainEntity"/> to <see cref="TagEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="domainModel">The domain model to be converted.</param>
|
||||
/// <param name="domainEntity">The domain entity to be converted.</param>
|
||||
/// <returns>The converted repository entity.</returns>
|
||||
public static TagEntity ToRepositoryEntity(this Tag domainModel)
|
||||
public static TagEntity ToRepositoryEntity(this Tag domainEntity)
|
||||
{
|
||||
return new TagEntity(
|
||||
domainModel.Name
|
||||
domainEntity.Name
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts <paramref name="domainModels"/> to a collection of <see cref="TagEntity"/>.
|
||||
/// Converts <paramref name="domainEntities"/> to a collection of <see cref="TagEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="domainModels">The domain model to be converted.</param>
|
||||
/// <param name="domainEntities">The domain entity to be converted.</param>
|
||||
/// <returns>The converted repository entities.</returns>
|
||||
public static IEnumerable<TagEntity> ToRepositoryEntities(this IEnumerable<Tag> domainModels)
|
||||
public static IEnumerable<TagEntity> ToRepositoryEntities(this IEnumerable<Tag> domainEntities)
|
||||
{
|
||||
return domainModels.Select(domainModel => domainModel.ToRepositoryEntity());
|
||||
return domainEntities.Select(domainEntity => domainEntity.ToRepositoryEntity());
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -2,7 +2,7 @@
|
||||
using ErrorOr;
|
||||
using Lumina.Contracts.Enums.FileSystem;
|
||||
using Lumina.Contracts.Responses.FileSystemManagement.Common;
|
||||
using Lumina.Domain.Core.Aggregates.FileSystemManagement.FileSystemManagementAggregate.Entities;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Entities;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.FileSystemManagement.Common;
|
||||
@@ -16,7 +16,7 @@ public static class FileSystemTreeNodeResponseMapping
|
||||
/// Converts <paramref name="response"/> to <see cref="WindowsRootItem"/>.
|
||||
/// </summary>
|
||||
/// <param name="response">The response to be converted.</param>
|
||||
/// <returns>The converted domain model.</returns>
|
||||
/// <returns>The converted domain entity.</returns>
|
||||
public static ErrorOr<WindowsRootItem> ToWindowsRootItem(this FileSystemTreeNodeResponse response)
|
||||
{
|
||||
return WindowsRootItem.Create(
|
||||
@@ -30,7 +30,7 @@ public static class FileSystemTreeNodeResponseMapping
|
||||
/// Converts <paramref name="_"/> to <see cref="UnixRootItem"/>.
|
||||
/// </summary>
|
||||
/// <param name="_">The response to be converted.</param>
|
||||
/// <returns>The converted domain model.</returns>
|
||||
/// <returns>The converted domain entity.</returns>
|
||||
public static ErrorOr<UnixRootItem> ToUnixRootItem(this FileSystemTreeNodeResponse _)
|
||||
{
|
||||
return UnixRootItem.Create(
|
||||
|
||||
+26
-26
@@ -2,7 +2,7 @@
|
||||
using Lumina.Application.Common.Mapping.FileSystemManagement.FileSystem;
|
||||
using Lumina.Contracts.Responses.FileSystemManagement.Common;
|
||||
using Lumina.Contracts.Responses.FileSystemManagement.Directories;
|
||||
using Lumina.Domain.Core.Aggregates.FileSystemManagement.FileSystemManagementAggregate.Entities;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Entities;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
@@ -15,58 +15,58 @@ namespace Lumina.Application.Common.Mapping.FileSystemManagement.Directories;
|
||||
public static class DirectoryMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="domainModel"/> to <see cref="FileSystemTreeNodeResponse"/>.
|
||||
/// Converts <paramref name="domainEntity"/> to <see cref="FileSystemTreeNodeResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="domainModel">The domain model to be converted.</param>
|
||||
/// <param name="domainEntity">The domain entity to be converted.</param>
|
||||
/// <returns>The converted response.</returns>
|
||||
public static FileSystemTreeNodeResponse ToFileSystemTreeNodeResponse(this Directory domainModel)
|
||||
public static FileSystemTreeNodeResponse ToFileSystemTreeNodeResponse(this Directory domainEntity)
|
||||
{
|
||||
return new FileSystemTreeNodeResponse()
|
||||
{
|
||||
Name = domainModel.Name,
|
||||
Path = domainModel.Id.Path,
|
||||
ItemType = domainModel.Type,
|
||||
Name = domainEntity.Name,
|
||||
Path = domainEntity.Id.Path,
|
||||
ItemType = domainEntity.Type,
|
||||
IsExpanded = false,
|
||||
ChildrenLoaded = false,
|
||||
Children = domainModel.Items.Select(item => item.ToTreeNodeResponse())
|
||||
.ToList()
|
||||
Children = domainEntity.Items.Select(item => item.ToTreeNodeResponse())
|
||||
.ToList()
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts <paramref name="domainModels"/> to a collection of <see cref="FileSystemTreeNodeResponse"/>.
|
||||
/// Converts <paramref name="domainEntities"/> to a collection of <see cref="FileSystemTreeNodeResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="domainModels">The domain models to be converted.</param>
|
||||
/// <param name="domainEntities">The domain entities to be converted.</param>
|
||||
/// <returns>The converted responses.</returns>
|
||||
public static IEnumerable<FileSystemTreeNodeResponse> ToFileSystemTreeNodeResponses(this IEnumerable<Directory> domainModels)
|
||||
public static IEnumerable<FileSystemTreeNodeResponse> ToFileSystemTreeNodeResponses(this IEnumerable<Directory> domainEntities)
|
||||
{
|
||||
return domainModels.Select(domainModel => domainModel.ToTreeNodeResponse());
|
||||
return domainEntities.Select(domainEntity => domainEntity.ToTreeNodeResponse());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts <paramref name="domainModel"/> to <see cref="DirectoryResponse"/>.
|
||||
/// Converts <paramref name="domainEntity"/> to <see cref="DirectoryResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="domainModel">The domain model to be converted.</param>
|
||||
/// <param name="domainEntity">The domain entity to be converted.</param>
|
||||
/// <returns>The converted response.</returns>
|
||||
public static DirectoryResponse ToResponse(this Directory domainModel)
|
||||
public static DirectoryResponse ToResponse(this Directory domainEntity)
|
||||
{
|
||||
return new DirectoryResponse(
|
||||
domainModel.Id.Path,
|
||||
domainModel.Name,
|
||||
domainModel.DateCreated.Value,
|
||||
domainModel.DateModified.Value,
|
||||
domainModel.Items.Select(fileSystemItem => fileSystemItem.ToFileSystemItemModel())
|
||||
.ToList()
|
||||
domainEntity.Id.Path,
|
||||
domainEntity.Name,
|
||||
domainEntity.DateCreated.Value,
|
||||
domainEntity.DateModified.Value,
|
||||
domainEntity.Items.Select(fileSystemItem => fileSystemItem.ToFileSystemItemEntity())
|
||||
.ToList()
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts <paramref name="domainModels"/> to a collection of <see cref="DirectoryResponse"/>.
|
||||
/// Converts <paramref name="domainEntities"/> to a collection of <see cref="DirectoryResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="domainModels">The domain models to be converted.</param>
|
||||
/// <param name="domainEntities">The domain entities to be converted.</param>
|
||||
/// <returns>The converted responses.</returns>
|
||||
public static IEnumerable<DirectoryResponse> ToResponses(this IEnumerable<Directory> domainModels)
|
||||
public static IEnumerable<DirectoryResponse> ToResponses(this IEnumerable<Directory> domainEntities)
|
||||
{
|
||||
return domainModels.Select(domainModel => domainModel.ToResponse());
|
||||
return domainEntities.Select(domainEntity => domainEntity.ToResponse());
|
||||
}
|
||||
}
|
||||
+21
-21
@@ -3,8 +3,8 @@ using Lumina.Application.Common.Mapping.FileSystemManagement.Directories;
|
||||
using Lumina.Application.Common.Mapping.FileSystemManagement.Files;
|
||||
using Lumina.Contracts.Entities.FileSystemManagement;
|
||||
using Lumina.Contracts.Responses.FileSystemManagement.Common;
|
||||
using Lumina.Domain.Core.Aggregates.FileSystemManagement.FileSystemManagementAggregate;
|
||||
using Lumina.Domain.Core.Aggregates.FileSystemManagement.FileSystemManagementAggregate.Entities;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -18,47 +18,47 @@ namespace Lumina.Application.Common.Mapping.FileSystemManagement.FileSystem;
|
||||
public static class FileSystemItemMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="domainModel"/> to <see cref="FileSystemItemEntity"/>.
|
||||
/// Converts <paramref name="domainEntity"/> to <see cref="FileSystemItemEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="domainModel">The domain model to be converted.</param>
|
||||
/// <returns>The converted model.</returns>
|
||||
public static FileSystemItemEntity ToFileSystemItemModel(this FileSystemItem domainModel)
|
||||
/// <param name="domainEntity">The domain entity to be converted.</param>
|
||||
/// <returns>The converted entity.</returns>
|
||||
public static FileSystemItemEntity ToFileSystemItemEntity(this FileSystemItem domainEntity)
|
||||
{
|
||||
return new FileSystemItemEntity(
|
||||
domainModel.Id.Path,
|
||||
domainModel.Name,
|
||||
domainEntity.Id.Path,
|
||||
domainEntity.Name,
|
||||
DateTime.Now,
|
||||
DateTime.Now
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts <paramref name="domainModel"/> to <see cref="FileSystemTreeNodeResponse"/>.
|
||||
/// Converts <paramref name="domainEntity"/> to <see cref="FileSystemTreeNodeResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="domainModel">The domain model to be converted.</param>
|
||||
/// <returns>The converted model.</returns>
|
||||
/// <param name="domainEntity">The domain entity to be converted.</param>
|
||||
/// <returns>The converted entity.</returns>
|
||||
/// <exception cref="ArgumentException">Thrown when the provided parameter is not an expected descendant of <see cref="FileSystemItem"/>.</exception>
|
||||
public static FileSystemTreeNodeResponse ToTreeNodeResponse(this FileSystemItem domainModel)
|
||||
public static FileSystemTreeNodeResponse ToTreeNodeResponse(this FileSystemItem domainEntity)
|
||||
{
|
||||
if (domainModel is Directory directory)
|
||||
if (domainEntity is Directory directory)
|
||||
return directory.ToFileSystemTreeNodeResponse();
|
||||
else if (domainModel is File file)
|
||||
else if (domainEntity is File file)
|
||||
return file.ToFileSystemTreeNodeResponse();
|
||||
else if (domainModel is WindowsRootItem windowsRootItem)
|
||||
else if (domainEntity is WindowsRootItem windowsRootItem)
|
||||
return windowsRootItem.ToTreeNodeResponse();
|
||||
else if (domainModel is UnixRootItem unixRootItem)
|
||||
else if (domainEntity is UnixRootItem unixRootItem)
|
||||
return unixRootItem.ToTreeNodeResponse();
|
||||
else
|
||||
throw new ArgumentException("Invalid FileSystemItem");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts <paramref name="domainModels"/> to <see cref="IEnumerable<FileSystemTreeNodeResponse>"/>.
|
||||
/// Converts <paramref name="domainEntities"/> to <see cref="IEnumerable<FileSystemTreeNodeResponse>"/>.
|
||||
/// </summary>
|
||||
/// <param name="domainModels">The domain models to be converted.</param>
|
||||
/// <returns>The converted models.</returns>
|
||||
public static IEnumerable<FileSystemTreeNodeResponse> ToTreeNodeResponses(this IEnumerable<FileSystemItem> domainModels)
|
||||
/// <param name="domainEntities">The domain entities to be converted.</param>
|
||||
/// <returns>The converted entities.</returns>
|
||||
public static IEnumerable<FileSystemTreeNodeResponse> ToTreeNodeResponses(this IEnumerable<FileSystemItem> domainEntities)
|
||||
{
|
||||
return domainModels.Select(domainModel => domainModel.ToTreeNodeResponse());
|
||||
return domainEntities.Select(domainEntity => domainEntity.ToTreeNodeResponse());
|
||||
}
|
||||
}
|
||||
+8
-8
@@ -1,7 +1,7 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.Enums.FileSystem;
|
||||
using Lumina.Contracts.Responses.FileSystemManagement.Common;
|
||||
using Lumina.Domain.Core.Aggregates.FileSystemManagement.FileSystemManagementAggregate.Entities;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Entities;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
@@ -13,21 +13,21 @@ namespace Lumina.Application.Common.Mapping.FileSystemManagement.FileSystem;
|
||||
public static class UnixRootItemMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="domainModel"/> to <see cref="FileSystemTreeNodeResponse"/>.
|
||||
/// Converts <paramref name="domainEntity"/> to <see cref="FileSystemTreeNodeResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="domainModel">The domain model to be converted.</param>
|
||||
/// <param name="domainEntity">The domain entity to be converted.</param>
|
||||
/// <returns>The converted response.</returns>
|
||||
public static FileSystemTreeNodeResponse ToTreeNodeResponse(this UnixRootItem domainModel)
|
||||
public static FileSystemTreeNodeResponse ToTreeNodeResponse(this UnixRootItem domainEntity)
|
||||
{
|
||||
return new FileSystemTreeNodeResponse()
|
||||
{
|
||||
Path = domainModel.Id.Path,
|
||||
Name = domainModel.Name,
|
||||
Path = domainEntity.Id.Path,
|
||||
Name = domainEntity.Name,
|
||||
ItemType = FileSystemItemType.Root,
|
||||
IsExpanded = false,
|
||||
ChildrenLoaded = false,
|
||||
Children = domainModel.Items.Select(item => item.ToTreeNodeResponse())
|
||||
.ToList()
|
||||
Children = domainEntity.Items.Select(item => item.ToTreeNodeResponse())
|
||||
.ToList()
|
||||
};
|
||||
}
|
||||
}
|
||||
+6
-9
@@ -1,10 +1,7 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.Mapping.FileSystemManagement.Common;
|
||||
using Lumina.Contracts.Enums.FileSystem;
|
||||
using Lumina.Contracts.Responses.FileSystemManagement.Common;
|
||||
using Lumina.Contracts.Responses.FileSystemManagement.Directories;
|
||||
using Lumina.Domain.Core.Aggregates.FileSystemManagement.FileSystemManagementAggregate.Entities;
|
||||
using System.Linq;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Entities;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.FileSystemManagement.FileSystem;
|
||||
@@ -15,16 +12,16 @@ namespace Lumina.Application.Common.Mapping.FileSystemManagement.FileSystem;
|
||||
public static class WindowsRootItemMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="domainModel"/> to <see cref="FileSystemTreeNodeResponse"/>.
|
||||
/// Converts <paramref name="domainEntity"/> to <see cref="FileSystemTreeNodeResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="domainModel">The domain model to be converted.</param>
|
||||
/// <param name="domainEntity">The domain entity to be converted.</param>
|
||||
/// <returns>The converted response.</returns>
|
||||
public static FileSystemTreeNodeResponse ToTreeNodeResponse(this WindowsRootItem domainModel)
|
||||
public static FileSystemTreeNodeResponse ToTreeNodeResponse(this WindowsRootItem domainEntity)
|
||||
{
|
||||
return new FileSystemTreeNodeResponse()
|
||||
{
|
||||
Path = domainModel.Id.Path,
|
||||
Name = domainModel.Name,
|
||||
Path = domainEntity.Id.Path,
|
||||
Name = domainEntity.Name,
|
||||
ItemType = FileSystemItemType.Root,
|
||||
IsExpanded = false
|
||||
};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.Responses.FileSystemManagement.Common;
|
||||
using Lumina.Contracts.Responses.FileSystemManagement.Files;
|
||||
using Lumina.Domain.Core.Aggregates.FileSystemManagement.FileSystemManagementAggregate.Entities;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Entities;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
@@ -14,55 +14,55 @@ namespace Lumina.Application.Common.Mapping.FileSystemManagement.Files;
|
||||
public static class FileMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="domainModel"/> to <see cref="FileSystemTreeNodeResponse"/>.
|
||||
/// Converts <paramref name="domainEntity"/> to <see cref="FileSystemTreeNodeResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="domainModel">The domain model to be converted.</param>
|
||||
/// <param name="domainEntity">The domain entity to be converted.</param>
|
||||
/// <returns>The converted response.</returns>
|
||||
public static FileSystemTreeNodeResponse ToFileSystemTreeNodeResponse(this File domainModel)
|
||||
public static FileSystemTreeNodeResponse ToFileSystemTreeNodeResponse(this File domainEntity)
|
||||
{
|
||||
return new FileSystemTreeNodeResponse()
|
||||
{
|
||||
Name = domainModel.Name,
|
||||
Path = domainModel.Id.Path,
|
||||
ItemType = domainModel.Type,
|
||||
Name = domainEntity.Name,
|
||||
Path = domainEntity.Id.Path,
|
||||
ItemType = domainEntity.Type,
|
||||
IsExpanded = false,
|
||||
ChildrenLoaded = false
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts <paramref name="domainModels"/> to a collection of <see cref="FileSystemTreeNodeResponse"/>.
|
||||
/// Converts <paramref name="domainEntities"/> to a collection of <see cref="FileSystemTreeNodeResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="domainModels">The domain models to be converted.</param>
|
||||
/// <param name="domainEntities">The domain entities to be converted.</param>
|
||||
/// <returns>The converted responses.</returns>
|
||||
public static IEnumerable<FileSystemTreeNodeResponse> ToFileSystemTreeNodeResponses(this IEnumerable<File> domainModels)
|
||||
public static IEnumerable<FileSystemTreeNodeResponse> ToFileSystemTreeNodeResponses(this IEnumerable<File> domainEntities)
|
||||
{
|
||||
return domainModels.Select(domainModel => domainModel.ToFileSystemTreeNodeResponse());
|
||||
return domainEntities.Select(domainEntity => domainEntity.ToFileSystemTreeNodeResponse());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts <paramref name="domainModel"/> to <see cref="FileResponse"/>.
|
||||
/// Converts <paramref name="domainEntity"/> to <see cref="FileResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="domainModel">The domain model to be converted.</param>
|
||||
/// <param name="domainEntity">The domain entity to be converted.</param>
|
||||
/// <returns>The converted response.</returns>
|
||||
public static FileResponse ToResponse(this File domainModel)
|
||||
public static FileResponse ToResponse(this File domainEntity)
|
||||
{
|
||||
return new FileResponse(
|
||||
domainModel.Id.Path,
|
||||
domainModel.Name,
|
||||
domainModel.DateCreated.HasValue ? domainModel.DateCreated.Value : default,
|
||||
domainModel.DateModified.HasValue ? domainModel.DateModified.Value : default,
|
||||
domainModel.Size
|
||||
domainEntity.Id.Path,
|
||||
domainEntity.Name,
|
||||
domainEntity.DateCreated.HasValue ? domainEntity.DateCreated.Value : default,
|
||||
domainEntity.DateModified.HasValue ? domainEntity.DateModified.Value : default,
|
||||
domainEntity.Size
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts <paramref name="domainModels"/> to a collection of <see cref="FileResponse"/>.
|
||||
/// Converts <paramref name="domainEntities"/> to a collection of <see cref="FileResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="domainModels">The domain models to be converted.</param>
|
||||
/// <param name="domainEntities">The domain entities to be converted.</param>
|
||||
/// <returns>The converted responses.</returns>
|
||||
public static IEnumerable<FileResponse> ToResponses(this IEnumerable<File> domainModels)
|
||||
public static IEnumerable<FileResponse> ToResponses(this IEnumerable<File> domainEntities)
|
||||
{
|
||||
return domainModels.Select(domainModel => domainModel.ToResponse());
|
||||
return domainEntities.Select(domainEntity => domainEntity.ToResponse());
|
||||
}
|
||||
}
|
||||
+9
-9
@@ -1,6 +1,6 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.Responses.FileSystemManagement.Path;
|
||||
using Lumina.Domain.Core.Aggregates.FileSystemManagement.FileSystemManagementAggregate.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
@@ -13,24 +13,24 @@ namespace Lumina.Application.Common.Mapping.FileSystemManagement.Paths;
|
||||
public static class PathSegmentMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="domainModel"/> to <see cref="PathSegmentResponse"/>.
|
||||
/// Converts <paramref name="domainEntity"/> to <see cref="PathSegmentResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="domainModel">The domain model to be converted.</param>
|
||||
/// <param name="domainEntity">The domain entity to be converted.</param>
|
||||
/// <returns>The converted response.</returns>
|
||||
public static PathSegmentResponse ToResponse(this PathSegment domainModel)
|
||||
public static PathSegmentResponse ToResponse(this PathSegment domainEntity)
|
||||
{
|
||||
return new PathSegmentResponse(
|
||||
domainModel.Name
|
||||
domainEntity.Name
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts <paramref name="domainModels"/> to a collection of <see cref="PathSegmentResponse"/>.
|
||||
/// Converts <paramref name="domainEntities"/> to a collection of <see cref="PathSegmentResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="domainModels">The domain models to be converted.</param>
|
||||
/// <param name="domainEntities">The domain entities to be converted.</param>
|
||||
/// <returns>The converted responses.</returns>
|
||||
public static IEnumerable<PathSegmentResponse> ToResponses(this IEnumerable<PathSegment> domainModels)
|
||||
public static IEnumerable<PathSegmentResponse> ToResponses(this IEnumerable<PathSegment> domainEntities)
|
||||
{
|
||||
return domainModels.Select(domainModel => domainModel.ToResponse());
|
||||
return domainEntities.Select(domainEntity => domainEntity.ToResponse());
|
||||
}
|
||||
}
|
||||
+6
-6
@@ -1,6 +1,6 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.Responses.FileSystemManagement.Thumbnails;
|
||||
using Lumina.Domain.Core.Aggregates.FileSystemManagement.FileSystemManagementAggregate.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.FileSystemManagement.Thumbnails;
|
||||
@@ -11,15 +11,15 @@ namespace Lumina.Application.Common.Mapping.FileSystemManagement.Thumbnails;
|
||||
public static class ThumbnailMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="domainModel"/> to <see cref="ThumbnailResponse"/>.
|
||||
/// Converts <paramref name="domainEntity"/> to <see cref="ThumbnailResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="domainModel">The domain model to be converted.</param>
|
||||
/// <param name="domainEntity">The domain entity to be converted.</param>
|
||||
/// <returns>The converted response.</returns>
|
||||
public static ThumbnailResponse ToResponse(this Thumbnail domainModel)
|
||||
public static ThumbnailResponse ToResponse(this Thumbnail domainEntity)
|
||||
{
|
||||
return new ThumbnailResponse(
|
||||
domainModel.Type,
|
||||
domainModel.Bytes
|
||||
domainEntity.Type,
|
||||
domainEntity.Bytes
|
||||
);
|
||||
}
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Core.MediaLibrary.Management.Commands.AddLibrary;
|
||||
using Lumina.Application.Core.MediaLibrary.WrittenContentLibrary.BooksLibrary.Books.Commands.AddBook;
|
||||
using Lumina.Contracts.Requests.MediaLibrary.Management;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.MediaLibrary.Management;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="AddLibraryRequest"/>.
|
||||
/// </summary>
|
||||
public static class AddMediaLibraryRequestMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="request"/> to <see cref="AddLibraryCommand"/>.
|
||||
/// </summary>
|
||||
/// <param name="request">The request to be converted.</param>
|
||||
/// <returns>The converted command.</returns>
|
||||
public static AddLibraryCommand ToCommand(this AddLibraryRequest request)
|
||||
{
|
||||
return new AddLibraryCommand(
|
||||
request.UserId,
|
||||
request.Title,
|
||||
request.LibraryType,
|
||||
request.ContentLocations
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.Entities.MediaLibrary.Management;
|
||||
using Lumina.Contracts.Responses.MediaLibrary.Management;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.MediaLibrary.Management;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="LibraryEntity"/>.
|
||||
/// </summary>
|
||||
public static class LibraryEntityMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="repositoryEntity"/> to <see cref="LibraryResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="repositoryEntity">The repository entity to be converted.</param>
|
||||
/// <returns>The converted response entity.</returns>
|
||||
public static LibraryResponse ToResponse(this LibraryEntity repositoryEntity)
|
||||
{
|
||||
return new LibraryResponse(
|
||||
repositoryEntity.Id,
|
||||
repositoryEntity.UserId,
|
||||
repositoryEntity.Title,
|
||||
repositoryEntity.LibraryType,
|
||||
repositoryEntity.ContentLocations.Select(location => location.Path).ToList(),
|
||||
repositoryEntity.Created,
|
||||
repositoryEntity.Updated
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.Entities.MediaLibrary.Management;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.MediaLibrary.Management;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="Library"/>.
|
||||
/// </summary>
|
||||
public static class LibraryMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="domainEntity"/> to <see cref="LibraryEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="domainEntity">The domain entity to be converted.</param>
|
||||
/// <returns>The converted repository entity.</returns>
|
||||
public static LibraryEntity ToRepositoryEntity(this Library domainEntity)
|
||||
{
|
||||
return new LibraryEntity
|
||||
{
|
||||
Id = domainEntity.Id.Value,
|
||||
Title = domainEntity.Title,
|
||||
LibraryType = domainEntity.LibraryType,
|
||||
UserId = domainEntity.UserId.Value,
|
||||
ContentLocations = domainEntity.ContentLocations.Select(path => new LibraryContentLocationEntity() { Path = path.Path }).ToList(),
|
||||
Created = domainEntity.Created,
|
||||
Updated = domainEntity.Updated.HasValue ? domainEntity.Updated : null
|
||||
};
|
||||
}
|
||||
}
|
||||
+4
-3
@@ -1,9 +1,10 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Core.WrittenContentLibrary.BooksLibrary.Books.Commands.AddBook;
|
||||
using Lumina.Contracts.Requests.WrittenContentLibrary.BookLibrary.Books;
|
||||
using Lumina.Application.Core.MediaLibrary.WrittenContentLibrary.BooksLibrary.Books.Commands.AddBook;
|
||||
using Lumina.Contracts.Requests.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.WrittenContentLibrary.BookLibrary.Books;
|
||||
namespace Lumina.Application.Common.Mapping.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="AddBookRequest"/>.
|
||||
+39
-38
@@ -1,54 +1,55 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Application.Common.Mapping.Common.Metadata;
|
||||
using Lumina.Application.Common.Mapping.WrittenContentLibrary.BookLibrary.Common;
|
||||
using Lumina.Application.Common.Mapping.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
|
||||
using Lumina.Application.Common.Mapping.MediaLibrary.WrittenContentLibrary.BookLibrary.Common;
|
||||
using Lumina.Contracts.Entities.Common;
|
||||
using Lumina.Contracts.Entities.WrittenContentLibrary;
|
||||
using Lumina.Contracts.Entities.WrittenContentLibrary.BookLibrary;
|
||||
using Lumina.Contracts.Entities.MediaLibrary.WrittenContentLibrary;
|
||||
using Lumina.Contracts.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary;
|
||||
using Lumina.Contracts.Enums.BookLibrary;
|
||||
using Lumina.Contracts.Responses.WrittenContentLibrary.BookLibrary.Books;
|
||||
using Lumina.Contracts.Responses.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Common.ValueObjects.Metadata;
|
||||
using Lumina.Domain.Core.Aggregates.WrittenContentLibrary.BookLibraryAggregate;
|
||||
using Lumina.Domain.Core.Aggregates.WrittenContentLibrary.BookLibraryAggregate.Entities;
|
||||
using Lumina.Domain.Core.Aggregates.WrittenContentLibrary.BookLibraryAggregate.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate;
|
||||
using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.Entities;
|
||||
using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.ValueObjects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.WrittenContentLibrary.BookLibrary.Books;
|
||||
namespace Lumina.Application.Common.Mapping.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="BookEntity"/>.
|
||||
/// </summary>
|
||||
public static class BookModelMapping
|
||||
public static class BookEntityMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="repositoryEntity"/> to <see cref="Book"/>.
|
||||
/// </summary>
|
||||
/// <param name="repositoryEntity">The repository model to be converted.</param>
|
||||
/// <param name="repositoryEntity">The repository entity to be converted.</param>
|
||||
/// <returns>
|
||||
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully converted <see cref="Book"/>, or an error message.
|
||||
/// </returns>
|
||||
public static ErrorOr<Book> ToDomainModel(this BookEntity repositoryEntity)
|
||||
public static ErrorOr<Book> ToDomainEntity(this BookEntity repositoryEntity)
|
||||
{
|
||||
IEnumerable<ErrorOr<Tag>> tagsResult = repositoryEntity.Tags.ToDomainModels();
|
||||
IEnumerable<ErrorOr<Tag>> tagsResult = repositoryEntity.Tags.ToDomainEntities();
|
||||
foreach (ErrorOr<Tag> tagResult in tagsResult)
|
||||
if (tagResult.IsError)
|
||||
return tagResult.Errors;
|
||||
|
||||
IEnumerable<ErrorOr<Genre>> genresResult = repositoryEntity.Genres.ToDomainModels();
|
||||
IEnumerable<ErrorOr<Genre>> genresResult = repositoryEntity.Genres.ToDomainEntities();
|
||||
foreach (ErrorOr<Genre> genreResult in genresResult)
|
||||
if (genreResult.IsError)
|
||||
return genreResult.Errors;
|
||||
|
||||
IEnumerable<ErrorOr<Isbn>> isbnsResult = repositoryEntity.ISBNs.ToDomainModels();
|
||||
IEnumerable<ErrorOr<Isbn>> isbnsResult = repositoryEntity.ISBNs.ToDomainEntities();
|
||||
foreach (ErrorOr<Isbn> isbnResult in isbnsResult)
|
||||
if (isbnResult.IsError)
|
||||
return isbnResult.Errors;
|
||||
|
||||
IEnumerable<ErrorOr<BookRating>> bookRatingsResult = repositoryEntity.Ratings.ToDomainModels();
|
||||
IEnumerable<ErrorOr<BookRating>> bookRatingsResult = repositoryEntity.Ratings.ToDomainEntities();
|
||||
foreach (ErrorOr<BookRating> bookRatingResult in bookRatingsResult)
|
||||
if (bookRatingResult.IsError)
|
||||
return bookRatingResult.Errors;
|
||||
@@ -63,7 +64,7 @@ public static class BookModelMapping
|
||||
);
|
||||
if (releaseInfoResult.IsError)
|
||||
return releaseInfoResult.Errors;
|
||||
|
||||
|
||||
Optional<LanguageInfo> languageInfo = Optional<LanguageInfo>.None();
|
||||
if (repositoryEntity.LanguageCode is not null)
|
||||
{
|
||||
@@ -105,8 +106,8 @@ public static class BookModelMapping
|
||||
if (writtenContentMetadataResult.IsError)
|
||||
return writtenContentMetadataResult.Errors;
|
||||
|
||||
Optional<BookFormat> bookFormat = Optional<BookFormat>.FromNullable(!string.IsNullOrWhiteSpace(repositoryEntity.Format) ? Enum.Parse<BookFormat>(repositoryEntity.Format) : (BookFormat?)null);
|
||||
|
||||
Optional<BookFormat> bookFormat = Optional<BookFormat>.FromNullable(repositoryEntity.Format);
|
||||
|
||||
return Book.Create(
|
||||
BookId.Create(repositoryEntity.Id),
|
||||
writtenContentMetadataResult.Value,
|
||||
@@ -133,24 +134,24 @@ public static class BookModelMapping
|
||||
/// <summary>
|
||||
/// Converts <paramref name="repositoryEntities"/> to a collection of <see cref="Book"/>.
|
||||
/// </summary>
|
||||
/// <param name="repositoryEntities">The repository models to be converted.</param>
|
||||
/// <returns>The converted domain models.</returns>
|
||||
/// <param name="repositoryEntities">The repository entities to be converted.</param>
|
||||
/// <returns>The converted domain entities.</returns>
|
||||
/// <returns>
|
||||
/// An colection of <see cref="ErrorOr{TValue}"/> containing either successfully converted <see cref="Book"/>, or error messages.
|
||||
/// </returns>
|
||||
public static IEnumerable<ErrorOr<Book>> ToDomainModels(this IEnumerable<BookEntity> repositoryEntities)
|
||||
public static IEnumerable<ErrorOr<Book>> ToDomainEntities(this IEnumerable<BookEntity> repositoryEntities)
|
||||
{
|
||||
return repositoryEntities.Select(repositoryEntity => repositoryEntity.ToDomainModel());
|
||||
return repositoryEntities.Select(repositoryEntity => repositoryEntity.ToDomainEntity());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts <paramref name="repositoryEntity"/> to <see cref="BookResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="repositoryEntity">The repository model to be converted.</param>
|
||||
/// <returns>The converted response model.</returns>
|
||||
/// <param name="repositoryEntity">The repository entity to be converted.</param>
|
||||
/// <returns>The converted response entity.</returns>
|
||||
public static BookResponse ToResponse(this BookEntity repositoryEntity)
|
||||
{
|
||||
ReleaseInfoEntity releaseInfoModel = new(
|
||||
ReleaseInfoEntity releaseInfoEntity = new(
|
||||
repositoryEntity.OriginalReleaseDate,
|
||||
repositoryEntity.OriginalReleaseYear,
|
||||
repositoryEntity.ReReleaseDate,
|
||||
@@ -159,38 +160,38 @@ public static class BookModelMapping
|
||||
repositoryEntity.ReleaseVersion
|
||||
);
|
||||
// language and original language make sense only if their subproperties have values
|
||||
LanguageInfoEntity? languageInfoModel = (!string.IsNullOrWhiteSpace(repositoryEntity.LanguageCode) ||
|
||||
LanguageInfoEntity? languageInfoEntity = !string.IsNullOrWhiteSpace(repositoryEntity.LanguageCode) ||
|
||||
!string.IsNullOrWhiteSpace(repositoryEntity.LanguageName) ||
|
||||
!string.IsNullOrWhiteSpace(repositoryEntity.LanguageNativeName))
|
||||
!string.IsNullOrWhiteSpace(repositoryEntity.LanguageNativeName)
|
||||
? new LanguageInfoEntity(
|
||||
repositoryEntity.LanguageCode,
|
||||
repositoryEntity.LanguageName,
|
||||
repositoryEntity.LanguageNativeName
|
||||
) : null;
|
||||
LanguageInfoEntity? originalLanguageInfoModel = (!string.IsNullOrWhiteSpace(repositoryEntity.OriginalLanguageCode) ||
|
||||
LanguageInfoEntity? originalLanguageInfoEntity = !string.IsNullOrWhiteSpace(repositoryEntity.OriginalLanguageCode) ||
|
||||
!string.IsNullOrWhiteSpace(repositoryEntity.OriginalLanguageName) ||
|
||||
!string.IsNullOrWhiteSpace(repositoryEntity.OriginalLanguageNativeName))
|
||||
!string.IsNullOrWhiteSpace(repositoryEntity.OriginalLanguageNativeName)
|
||||
? new LanguageInfoEntity(
|
||||
repositoryEntity.OriginalLanguageCode,
|
||||
repositoryEntity.OriginalLanguageName,
|
||||
repositoryEntity.OriginalLanguageNativeName
|
||||
) : null;
|
||||
WrittenContentMetadataEntity metadata = new(
|
||||
repositoryEntity.Title,
|
||||
repositoryEntity.OriginalTitle,
|
||||
repositoryEntity.Title,
|
||||
repositoryEntity.OriginalTitle,
|
||||
repositoryEntity.Description,
|
||||
releaseInfoModel,
|
||||
releaseInfoEntity,
|
||||
[.. repositoryEntity.Genres],
|
||||
[.. repositoryEntity.Tags],
|
||||
languageInfoModel,
|
||||
originalLanguageInfoModel,
|
||||
languageInfoEntity,
|
||||
originalLanguageInfoEntity,
|
||||
repositoryEntity.Publisher,
|
||||
repositoryEntity.PageCount
|
||||
);
|
||||
return new BookResponse(
|
||||
repositoryEntity.Id,
|
||||
repositoryEntity.Id,
|
||||
metadata,
|
||||
!string.IsNullOrWhiteSpace(repositoryEntity.Format) ? Enum.Parse<BookFormat>(repositoryEntity.Format) : null,
|
||||
repositoryEntity.Format,
|
||||
repositoryEntity.Edition,
|
||||
repositoryEntity.VolumeNumber,
|
||||
null,
|
||||
@@ -198,7 +199,7 @@ public static class BookModelMapping
|
||||
repositoryEntity.GoodreadsId,
|
||||
repositoryEntity.LCCN,
|
||||
repositoryEntity.OCLCNumber,
|
||||
repositoryEntity.OpenLibraryId,
|
||||
repositoryEntity.OpenLibraryId,
|
||||
repositoryEntity.LibraryThingId,
|
||||
repositoryEntity.GoogleBooksId,
|
||||
repositoryEntity.BarnesAndNobleId,
|
||||
@@ -214,7 +215,7 @@ public static class BookModelMapping
|
||||
/// <summary>
|
||||
/// Converts <paramref name="repositoryEntities"/> to a collection of <see cref="Book"/>.
|
||||
/// </summary>
|
||||
/// <param name="repositoryEntities">The repository models to be converted.</param>
|
||||
/// <param name="repositoryEntities">The repository entities to be converted.</param>
|
||||
/// <returns>The converted reponses.</returns>
|
||||
public static IEnumerable<BookResponse> ToResponses(this IEnumerable<BookEntity> repositoryEntities)
|
||||
{
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.Mapping.Common.Metadata;
|
||||
using Lumina.Application.Common.Mapping.MediaLibrary.WrittenContentLibrary.BookLibrary.Common;
|
||||
using Lumina.Contracts.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary;
|
||||
using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="Book"/>.
|
||||
/// </summary>
|
||||
public static class BookMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="domainEntity"/> to <see cref="BookEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="domainEntity">The domain entity to be converted.</param>
|
||||
/// <returns>The converted repository entity.</returns>
|
||||
public static BookEntity ToRepositoryEntity(this Book domainEntity)
|
||||
{
|
||||
return new BookEntity
|
||||
{
|
||||
Id = domainEntity.Id.Value,
|
||||
Title = domainEntity.Metadata.Title,
|
||||
OriginalTitle = domainEntity.Metadata.OriginalTitle.HasValue ? domainEntity.Metadata.OriginalTitle.Value : null,
|
||||
Description = domainEntity.Metadata.Description.HasValue ? domainEntity.Metadata.Description.Value : null,
|
||||
OriginalReleaseDate = domainEntity.Metadata.ReleaseInfo.OriginalReleaseDate.HasValue ? domainEntity.Metadata.ReleaseInfo.OriginalReleaseDate.Value : null,
|
||||
OriginalReleaseYear = domainEntity.Metadata.ReleaseInfo.OriginalReleaseYear.HasValue ? domainEntity.Metadata.ReleaseInfo.OriginalReleaseYear.Value : null,
|
||||
ReReleaseDate = domainEntity.Metadata.ReleaseInfo.ReReleaseDate.HasValue ? domainEntity.Metadata.ReleaseInfo.ReReleaseDate.Value : null,
|
||||
ReReleaseYear = domainEntity.Metadata.ReleaseInfo.ReReleaseYear.HasValue ? domainEntity.Metadata.ReleaseInfo.ReReleaseYear.Value : null,
|
||||
ReleaseCountry = domainEntity.Metadata.ReleaseInfo.ReleaseCountry.HasValue ? domainEntity.Metadata.ReleaseInfo.ReleaseCountry.Value : null,
|
||||
ReleaseVersion = domainEntity.Metadata.ReleaseInfo.ReleaseVersion.HasValue ? domainEntity.Metadata.ReleaseInfo.ReleaseVersion.Value : null,
|
||||
LanguageCode = domainEntity.Metadata.Language.HasValue ? domainEntity.Metadata.Language.Value.LanguageCode : null,
|
||||
LanguageName = domainEntity.Metadata.Language.HasValue ? domainEntity.Metadata.Language.Value.LanguageName : null,
|
||||
LanguageNativeName = domainEntity.Metadata.Language.HasValue ? domainEntity.Metadata.Language.Value.NativeName.Value : null,
|
||||
OriginalLanguageCode = domainEntity.Metadata.OriginalLanguage.HasValue ? domainEntity.Metadata.OriginalLanguage.Value.LanguageCode : null,
|
||||
OriginalLanguageName = domainEntity.Metadata.OriginalLanguage.HasValue ? domainEntity.Metadata.OriginalLanguage.Value.LanguageName : null,
|
||||
OriginalLanguageNativeName = domainEntity.Metadata.OriginalLanguage.HasValue ? domainEntity.Metadata.OriginalLanguage.Value.NativeName.Value : null,
|
||||
Tags = domainEntity.Metadata.Tags.ToRepositoryEntities().ToHashSet(),
|
||||
Genres = domainEntity.Metadata.Genres.ToRepositoryEntities().ToHashSet(),
|
||||
Publisher = domainEntity.Metadata.Publisher.HasValue ? domainEntity.Metadata.Publisher.Value : null,
|
||||
PageCount = domainEntity.Metadata.PageCount.HasValue ? domainEntity.Metadata.PageCount.Value : null,
|
||||
Format = domainEntity.Format.HasValue ? domainEntity.Format.Value : null,
|
||||
Edition = domainEntity.Edition.HasValue ? domainEntity.Edition.Value : null,
|
||||
VolumeNumber = domainEntity.VolumeNumber.HasValue ? domainEntity.VolumeNumber.Value : null,
|
||||
ASIN = domainEntity.ASIN.HasValue ? domainEntity.ASIN.Value : null,
|
||||
GoodreadsId = domainEntity.GoodreadsId.HasValue ? domainEntity.GoodreadsId.Value : null,
|
||||
LCCN = domainEntity.LCCN.HasValue ? domainEntity.LCCN.Value : null,
|
||||
OCLCNumber = domainEntity.OCLCNumber.HasValue ? domainEntity.OCLCNumber.Value : null,
|
||||
OpenLibraryId = domainEntity.OpenLibraryId.HasValue ? domainEntity.OpenLibraryId.Value : null,
|
||||
LibraryThingId = domainEntity.LibraryThingId.HasValue ? domainEntity.LibraryThingId.Value : null,
|
||||
GoogleBooksId = domainEntity.GoogleBooksId.HasValue ? domainEntity.GoogleBooksId.Value : null,
|
||||
BarnesAndNobleId = domainEntity.BarnesAndNobleId.HasValue ? domainEntity.BarnesAndNobleId.Value : null,
|
||||
AppleBooksId = domainEntity.AppleBooksId.HasValue ? domainEntity.AppleBooksId.Value : null,
|
||||
ISBNs = domainEntity.ISBNs.ToRepositoryEntities().ToList(),
|
||||
Ratings = domainEntity.Ratings.ToRepositoryEntities().ToList(),
|
||||
Created = domainEntity.Created,
|
||||
Updated = domainEntity.Updated.HasValue ? domainEntity.Updated : null
|
||||
};
|
||||
}
|
||||
}
|
||||
+11
-11
@@ -1,26 +1,26 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Contracts.Entities.WrittenContentLibrary.BookLibrary;
|
||||
using Lumina.Contracts.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary;
|
||||
using Lumina.Contracts.Enums.BookLibrary;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.Aggregates.WrittenContentLibrary.BookLibraryAggregate.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.ValueObjects;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.WrittenContentLibrary.BookLibrary.Common;
|
||||
namespace Lumina.Application.Common.Mapping.MediaLibrary.WrittenContentLibrary.BookLibrary.Common;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="BookRatingEntity"/>.
|
||||
/// </summary>
|
||||
public static class BookRatingModelMapping
|
||||
public static class BookRatingEntityMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="repositoryEntity"/> to <see cref="BookRating"/>.
|
||||
/// </summary>
|
||||
/// <param name="repositoryEntity">The repository model to be converted.</param>
|
||||
/// <returns>The converted domain model.</returns>
|
||||
public static ErrorOr<BookRating> ToDomainModel(this BookRatingEntity repositoryEntity)
|
||||
/// <param name="repositoryEntity">The repository entity to be converted.</param>
|
||||
/// <returns>The converted domain entity.</returns>
|
||||
public static ErrorOr<BookRating> ToDomainEntity(this BookRatingEntity repositoryEntity)
|
||||
{
|
||||
return BookRating.Create(
|
||||
repositoryEntity.Value ?? default,
|
||||
@@ -33,10 +33,10 @@ public static class BookRatingModelMapping
|
||||
/// <summary>
|
||||
/// Converts <paramref name="repositoryEntities"/> to a collection of <see cref="BookRating"/>.
|
||||
/// </summary>
|
||||
/// <param name="repositoryEntities">The repository models to be converted.</param>
|
||||
/// <returns>The converted domain models.</returns>
|
||||
public static IEnumerable<ErrorOr<BookRating>> ToDomainModels(this IEnumerable<BookRatingEntity> repositoryEntities)
|
||||
/// <param name="repositoryEntities">The repository entities to be converted.</param>
|
||||
/// <returns>The converted domain entities.</returns>
|
||||
public static IEnumerable<ErrorOr<BookRating>> ToDomainEntities(this IEnumerable<BookRatingEntity> repositoryEntities)
|
||||
{
|
||||
return repositoryEntities.Select(domainModel => domainModel.ToDomainModel());
|
||||
return repositoryEntities.Select(domainEntity => domainEntity.ToDomainEntity());
|
||||
}
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.Entities.MediaLibrary.WrittenContentLibrary.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="BookRating"/>.
|
||||
/// </summary>
|
||||
public static class BookRatingMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="domainEntity"/> to <see cref="BookRatingEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="domainEntity">The domain entity to be converted.</param>
|
||||
/// <returns>The converted repository entity.</returns>
|
||||
public static BookRatingEntity ToRepositoryEntity(this BookRating domainEntity)
|
||||
{
|
||||
return new BookRatingEntity(
|
||||
domainEntity.Value,
|
||||
domainEntity.MaxValue,
|
||||
domainEntity.Source.HasValue ? domainEntity.Source.Value : null,
|
||||
domainEntity.VoteCount.HasValue ? domainEntity.VoteCount.Value : null
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts <paramref name="domainEntities"/> to a collection of <see cref="BookRatingEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="domainEntities">The domain entities to be converted.</param>
|
||||
/// <returns>The converted repository entities.</returns>
|
||||
public static IEnumerable<BookRatingEntity> ToRepositoryEntities(this IEnumerable<BookRating> domainEntities)
|
||||
{
|
||||
return domainEntities.Select(domainEntity => domainEntity.ToRepositoryEntity());
|
||||
}
|
||||
}
|
||||
+10
-10
@@ -1,27 +1,27 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Contracts.Entities.WrittenContentLibrary.BookLibrary;
|
||||
using Lumina.Contracts.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary;
|
||||
using Lumina.Contracts.Enums.BookLibrary;
|
||||
using Lumina.Domain.Core.Aggregates.WrittenContentLibrary.BookLibraryAggregate.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.ValueObjects;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.WrittenContentLibrary.BookLibrary.Common;
|
||||
namespace Lumina.Application.Common.Mapping.MediaLibrary.WrittenContentLibrary.BookLibrary.Common;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="IsbnEntity"/>.
|
||||
/// </summary>
|
||||
public static class IsbnModelMapping
|
||||
public static class IsbnEntityMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="repositoryEntity"/> to <see cref="Isbn"/>.
|
||||
/// </summary>
|
||||
/// <param name="repositoryEntity">The repository model to be converted.</param>
|
||||
/// <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> ToDomainModel(this IsbnEntity repositoryEntity)
|
||||
public static ErrorOr<Isbn> ToDomainEntity(this IsbnEntity repositoryEntity)
|
||||
{
|
||||
return Isbn.Create(
|
||||
repositoryEntity.Value,
|
||||
@@ -32,10 +32,10 @@ public static class IsbnModelMapping
|
||||
/// <summary>
|
||||
/// Converts <paramref name="repositoryEntities"/> to a collection of <see cref="Isbn"/>.
|
||||
/// </summary>
|
||||
/// <param name="repositoryEntities">The repository models to be converted.</param>
|
||||
/// <returns>The converted domain models.</returns>
|
||||
public static IEnumerable<ErrorOr<Isbn>> ToDomainModels(this IEnumerable<IsbnEntity> repositoryEntities)
|
||||
/// <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(domainModel => domainModel.ToDomainModel());
|
||||
return repositoryEntities.Select(domainEntity => domainEntity.ToDomainEntity());
|
||||
}
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.Entities.MediaLibrary.WrittenContentLibrary.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="Isbn"/>.
|
||||
/// </summary>
|
||||
public static class IsbnMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="domainEntity"/> to <see cref="IsbnEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="domainEntity">The domain entity to be converted.</param>
|
||||
/// <returns>The converted repository entity.</returns>
|
||||
public static IsbnEntity ToRepositoryEntity(this Isbn domainEntity)
|
||||
{
|
||||
return new IsbnEntity(
|
||||
domainEntity.Value,
|
||||
domainEntity.Format
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts <paramref name="domainEntities"/> to a collection of <see cref="IsbnEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="domainEntities">The domain entities to be converted.</param>
|
||||
/// <returns>The converted repository entities.</returns>
|
||||
public static IEnumerable<IsbnEntity> ToRepositoryEntities(this IEnumerable<Isbn> domainEntities)
|
||||
{
|
||||
return domainEntities.Select(domainEntity => domainEntity.ToRepositoryEntity());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.Entities.UsersManagement;
|
||||
using Lumina.Contracts.Responses.UsersManagement.Users;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.UsersManagement.Users;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="UserEntity"/>.
|
||||
/// </summary>
|
||||
public static class UserEntityMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="repositoryEntity"/> to <see cref="UserResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="repositoryEntity">The repository entity to be converted.</param>
|
||||
/// <returns>The converted response entity.</returns>
|
||||
public static UserResponse ToResponse(this UserEntity repositoryEntity)
|
||||
{
|
||||
return new UserResponse(
|
||||
repositoryEntity.Id,
|
||||
repositoryEntity.Username,
|
||||
repositoryEntity.Created,
|
||||
repositoryEntity.Updated
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -11,19 +11,19 @@ namespace Lumina.Application.Common.Mapping.UsersManagement.Users;
|
||||
public static class UserMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="domainModel"/> to <see cref="UserEntity"/>.
|
||||
/// Converts <paramref name="domainEntity"/> to <see cref="UserEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="domainModel">The domain model to be converted.</param>
|
||||
/// <param name="repositoryEntity">The repository entity containing sensitive information not mapped to the Domain model.</param>
|
||||
/// <param name="domainEntity">The domain entity to be converted.</param>
|
||||
/// <param name="repositoryEntity">The repository entity containing sensitive information not mapped to the Domain entity.</param>
|
||||
/// <remarks>
|
||||
/// Because Authentication and Authorization are Application Layer concerns, the members involved in those concerns are not mirrored in the Domain entity.
|
||||
/// However, since Entity Framework updates an entire entity, when mapping from the Domain entity to the DAL entity, one still needs to provide the
|
||||
/// values of the non-included members, such that they are not overriden with <see langword="null"/>. Those values should come in the requested <paramref name="repositoryEntity"/>.
|
||||
/// </remarks>
|
||||
/// <returns>The converted repository entity.</returns>
|
||||
public static UserEntity ToRepositoryEntity(this User domainModel, UserEntity repositoryEntity)
|
||||
public static UserEntity ToRepositoryEntity(this User domainEntity, UserEntity repositoryEntity)
|
||||
{
|
||||
repositoryEntity.Username = domainModel.Username;
|
||||
repositoryEntity.Username = domainEntity.Username;
|
||||
return repositoryEntity;
|
||||
}
|
||||
}
|
||||
-64
@@ -1,64 +0,0 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.Mapping.Common.Metadata;
|
||||
using Lumina.Application.Common.Mapping.WrittenContentLibrary.BookLibrary.Common;
|
||||
using Lumina.Contracts.Entities.WrittenContentLibrary.BookLibrary;
|
||||
using Lumina.Contracts.Responses.WrittenContentLibrary.BookLibrary.Books;
|
||||
using Lumina.Domain.Core.Aggregates.WrittenContentLibrary.BookLibraryAggregate;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.WrittenContentLibrary.BookLibrary.Books;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="Book"/>.
|
||||
/// </summary>
|
||||
public static class BookMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="domainModel"/> to <see cref="BookEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="domainModel">The domain model to be converted.</param>
|
||||
/// <returns>The converted repository entity.</returns>
|
||||
public static BookEntity ToRepositoryEntity(this Book domainModel)
|
||||
{
|
||||
return new BookEntity
|
||||
{
|
||||
Id = domainModel.Id.Value,
|
||||
Title = domainModel.Metadata.Title,
|
||||
OriginalTitle = domainModel.Metadata.OriginalTitle.HasValue ? domainModel.Metadata.OriginalTitle.Value : null,
|
||||
Description = domainModel.Metadata.Description.HasValue ? domainModel.Metadata.Description.Value : null,
|
||||
OriginalReleaseDate = domainModel.Metadata.ReleaseInfo.OriginalReleaseDate.HasValue ? domainModel.Metadata.ReleaseInfo.OriginalReleaseDate.Value : null,
|
||||
OriginalReleaseYear = domainModel.Metadata.ReleaseInfo.OriginalReleaseYear.HasValue ? domainModel.Metadata.ReleaseInfo.OriginalReleaseYear.Value : null,
|
||||
ReReleaseDate = domainModel.Metadata.ReleaseInfo.ReReleaseDate.HasValue ? domainModel.Metadata.ReleaseInfo.ReReleaseDate.Value : null,
|
||||
ReReleaseYear = domainModel.Metadata.ReleaseInfo.ReReleaseYear.HasValue ? domainModel.Metadata.ReleaseInfo.ReReleaseYear.Value : null,
|
||||
ReleaseCountry = domainModel.Metadata.ReleaseInfo.ReleaseCountry.HasValue ? domainModel.Metadata.ReleaseInfo.ReleaseCountry.Value : null,
|
||||
ReleaseVersion = domainModel.Metadata.ReleaseInfo.ReleaseVersion.HasValue ? domainModel.Metadata.ReleaseInfo.ReleaseVersion.Value : null,
|
||||
LanguageCode = domainModel.Metadata.Language.HasValue ? domainModel.Metadata.Language.Value.LanguageCode : null,
|
||||
LanguageName = domainModel.Metadata.Language.HasValue ? domainModel.Metadata.Language.Value.LanguageName : null,
|
||||
LanguageNativeName = domainModel.Metadata.Language.HasValue ? domainModel.Metadata.Language.Value.NativeName.Value : null,
|
||||
OriginalLanguageCode = domainModel.Metadata.OriginalLanguage.HasValue ? domainModel.Metadata.OriginalLanguage.Value.LanguageCode : null,
|
||||
OriginalLanguageName = domainModel.Metadata.OriginalLanguage.HasValue ? domainModel.Metadata.OriginalLanguage.Value.LanguageName : null,
|
||||
OriginalLanguageNativeName = domainModel.Metadata.OriginalLanguage.HasValue ? domainModel.Metadata.OriginalLanguage.Value.NativeName.Value : null,
|
||||
Tags = domainModel.Metadata.Tags.ToRepositoryEntities().ToHashSet(),
|
||||
Genres = domainModel.Metadata.Genres.ToRepositoryEntities().ToHashSet(),
|
||||
Publisher = domainModel.Metadata.Publisher.HasValue ? domainModel.Metadata.Publisher.Value : null,
|
||||
PageCount = domainModel.Metadata.PageCount.HasValue ? domainModel.Metadata.PageCount.Value : null,
|
||||
Format = domainModel.Format.ToString(),
|
||||
Edition = domainModel.Edition.HasValue ? domainModel.Edition.Value : null,
|
||||
VolumeNumber = domainModel.VolumeNumber.HasValue ? domainModel.VolumeNumber.Value : null,
|
||||
ASIN = domainModel.ASIN.HasValue ? domainModel.ASIN.Value : null,
|
||||
GoodreadsId = domainModel.GoodreadsId.HasValue ? domainModel.GoodreadsId.Value : null,
|
||||
LCCN = domainModel.LCCN.HasValue ? domainModel.LCCN.Value : null,
|
||||
OCLCNumber = domainModel.OCLCNumber.HasValue ? domainModel.OCLCNumber.Value : null,
|
||||
OpenLibraryId = domainModel.OpenLibraryId.HasValue ? domainModel.OpenLibraryId.Value : null,
|
||||
LibraryThingId = domainModel.LibraryThingId.HasValue ? domainModel.LibraryThingId.Value : null,
|
||||
GoogleBooksId = domainModel.GoogleBooksId.HasValue ? domainModel.GoogleBooksId.Value : null,
|
||||
BarnesAndNobleId = domainModel.BarnesAndNobleId.HasValue ? domainModel.BarnesAndNobleId.Value : null,
|
||||
AppleBooksId = domainModel.AppleBooksId.HasValue ? domainModel.AppleBooksId.Value : null,
|
||||
ISBNs = domainModel.ISBNs.ToRepositoryEntities().ToList(),
|
||||
Ratings = domainModel.Ratings.ToRepositoryEntities().ToList(),
|
||||
Created = domainModel.Created,
|
||||
Updated = domainModel.Updated.HasValue ? domainModel.Updated : null
|
||||
};
|
||||
}
|
||||
}
|
||||
-39
@@ -1,39 +0,0 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.Entities.WrittenContentLibrary.BookLibrary;
|
||||
using Lumina.Domain.Core.Aggregates.WrittenContentLibrary.BookLibraryAggregate.ValueObjects;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.WrittenContentLibrary.BookLibrary.Common;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="BookRating"/>.
|
||||
/// </summary>
|
||||
public static class BookRatingMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="domainModel"/> to <see cref="BookRatingEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="domainModel">The domain model to be converted.</param>
|
||||
/// <returns>The converted repository entity.</returns>
|
||||
public static BookRatingEntity ToRepositoryEntity(this BookRating domainModel)
|
||||
{
|
||||
return new BookRatingEntity(
|
||||
domainModel.Value,
|
||||
domainModel.MaxValue,
|
||||
domainModel.Source.HasValue ? domainModel.Source.Value : null,
|
||||
domainModel.VoteCount.HasValue ? domainModel.VoteCount.Value : null
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts <paramref name="domainModels"/> to a collection of <see cref="BookRatingEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="domainModels">The domain models to be converted.</param>
|
||||
/// <returns>The converted repository entities.</returns>
|
||||
public static IEnumerable<BookRatingEntity> ToRepositoryEntities(this IEnumerable<BookRating> domainModels)
|
||||
{
|
||||
return domainModels.Select(domainModel => domainModel.ToRepositoryEntity());
|
||||
}
|
||||
}
|
||||
-37
@@ -1,37 +0,0 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.Entities.WrittenContentLibrary.BookLibrary;
|
||||
using Lumina.Domain.Core.Aggregates.WrittenContentLibrary.BookLibraryAggregate.ValueObjects;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.WrittenContentLibrary.BookLibrary.Common;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="Isbn"/>.
|
||||
/// </summary>
|
||||
public static class IsbnMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="domainModel"/> to <see cref="IsbnEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="domainModel">The domain model to be converted.</param>
|
||||
/// <returns>The converted repository entity.</returns>
|
||||
public static IsbnEntity ToRepositoryEntity(this Isbn domainModel)
|
||||
{
|
||||
return new IsbnEntity(
|
||||
domainModel.Value,
|
||||
domainModel.Format
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts <paramref name="domainModels"/> to a collection of <see cref="IsbnEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="domainModels">The domain models to be converted.</param>
|
||||
/// <returns>The converted repository entities.</returns>
|
||||
public static IEnumerable<IsbnEntity> ToRepositoryEntities(this IEnumerable<Isbn> domainModels)
|
||||
{
|
||||
return domainModels.Select(domainModel => domainModel.ToRepositoryEntity());
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -2,8 +2,8 @@
|
||||
using ErrorOr;
|
||||
using Lumina.Application.Common.Mapping.FileSystemManagement.Directories;
|
||||
using Lumina.Contracts.Responses.FileSystemManagement.Directories;
|
||||
using Lumina.Domain.Core.Aggregates.FileSystemManagement.FileSystemManagementAggregate.Entities;
|
||||
using Lumina.Domain.Core.Aggregates.FileSystemManagement.FileSystemManagementAggregate.Services;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Services;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Entities;
|
||||
using Mediator;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
|
||||
+4
-4
@@ -3,10 +3,10 @@ using ErrorOr;
|
||||
using Lumina.Application.Common.Mapping.FileSystemManagement.FileSystem;
|
||||
using Lumina.Contracts.Enums.FileSystem;
|
||||
using Lumina.Contracts.Responses.FileSystemManagement.Common;
|
||||
using Lumina.Domain.Core.Aggregates.FileSystemManagement.FileSystemManagementAggregate;
|
||||
using Lumina.Domain.Core.Aggregates.FileSystemManagement.FileSystemManagementAggregate.Entities;
|
||||
using Lumina.Domain.Core.Aggregates.FileSystemManagement.FileSystemManagementAggregate.Services;
|
||||
using Lumina.Domain.Core.Aggregates.FileSystemManagement.FileSystemManagementAggregate.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Entities;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Services;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
|
||||
using Mediator;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
+2
-2
@@ -2,8 +2,8 @@
|
||||
using ErrorOr;
|
||||
using Lumina.Application.Common.Mapping.FileSystemManagement.Directories;
|
||||
using Lumina.Contracts.Responses.FileSystemManagement.Common;
|
||||
using Lumina.Domain.Core.Aggregates.FileSystemManagement.FileSystemManagementAggregate.Entities;
|
||||
using Lumina.Domain.Core.Aggregates.FileSystemManagement.FileSystemManagementAggregate.Services;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Services;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Entities;
|
||||
using Mediator;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
|
||||
+2
-2
@@ -2,8 +2,8 @@
|
||||
using ErrorOr;
|
||||
using Lumina.Application.Common.Mapping.FileSystemManagement.FileSystem;
|
||||
using Lumina.Contracts.Responses.FileSystemManagement.Common;
|
||||
using Lumina.Domain.Core.Aggregates.FileSystemManagement.FileSystemManagementAggregate;
|
||||
using Lumina.Domain.Core.Aggregates.FileSystemManagement.FileSystemManagementAggregate.Services;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Services;
|
||||
using Mediator;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.Responses.FileSystemManagement.FileSystem;
|
||||
using Lumina.Domain.Core.Aggregates.FileSystemManagement.FileSystemManagementAggregate.Strategies.Platform;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Strategies.Platform;
|
||||
using Mediator;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
+2
-2
@@ -2,8 +2,8 @@
|
||||
using ErrorOr;
|
||||
using Lumina.Application.Common.Mapping.FileSystemManagement.Files;
|
||||
using Lumina.Contracts.Responses.FileSystemManagement.Files;
|
||||
using Lumina.Domain.Core.Aggregates.FileSystemManagement.FileSystemManagementAggregate.Entities;
|
||||
using Lumina.Domain.Core.Aggregates.FileSystemManagement.FileSystemManagementAggregate.Services;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Entities;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Services;
|
||||
using Mediator;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
|
||||
+2
-2
@@ -2,8 +2,8 @@
|
||||
using ErrorOr;
|
||||
using Lumina.Application.Common.Mapping.FileSystemManagement.Files;
|
||||
using Lumina.Contracts.Responses.FileSystemManagement.Common;
|
||||
using Lumina.Domain.Core.Aggregates.FileSystemManagement.FileSystemManagementAggregate.Entities;
|
||||
using Lumina.Domain.Core.Aggregates.FileSystemManagement.FileSystemManagementAggregate.Services;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Entities;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Services;
|
||||
using Mediator;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
using ErrorOr;
|
||||
using Lumina.Application.Core.FileSystemManagement.Paths.Commands.SplitPath;
|
||||
using Lumina.Contracts.Responses.FileSystemManagement.Path;
|
||||
using Lumina.Domain.Core.Aggregates.FileSystemManagement.FileSystemManagementAggregate.Services;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Services;
|
||||
using Mediator;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
+2
-2
@@ -2,8 +2,8 @@
|
||||
using ErrorOr;
|
||||
using Lumina.Application.Common.Mapping.FileSystemManagement.Paths;
|
||||
using Lumina.Contracts.Responses.FileSystemManagement.Path;
|
||||
using Lumina.Domain.Core.Aggregates.FileSystemManagement.FileSystemManagementAggregate.Services;
|
||||
using Lumina.Domain.Core.Aggregates.FileSystemManagement.FileSystemManagementAggregate.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Services;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
|
||||
using Mediator;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.Responses.FileSystemManagement.Path;
|
||||
using Lumina.Domain.Core.Aggregates.FileSystemManagement.FileSystemManagementAggregate.Services;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Services;
|
||||
using Mediator;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
+2
-2
@@ -2,8 +2,8 @@
|
||||
using ErrorOr;
|
||||
using Lumina.Application.Common.Mapping.FileSystemManagement.Paths;
|
||||
using Lumina.Contracts.Responses.FileSystemManagement.Path;
|
||||
using Lumina.Domain.Core.Aggregates.FileSystemManagement.FileSystemManagementAggregate.Services;
|
||||
using Lumina.Domain.Core.Aggregates.FileSystemManagement.FileSystemManagementAggregate.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Services;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
|
||||
using Mediator;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
|
||||
+2
-2
@@ -2,8 +2,8 @@
|
||||
using ErrorOr;
|
||||
using Lumina.Application.Common.Mapping.FileSystemManagement.Paths;
|
||||
using Lumina.Contracts.Responses.FileSystemManagement.Path;
|
||||
using Lumina.Domain.Core.Aggregates.FileSystemManagement.FileSystemManagementAggregate.Services;
|
||||
using Lumina.Domain.Core.Aggregates.FileSystemManagement.FileSystemManagementAggregate.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Services;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
|
||||
using Mediator;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.Responses.FileSystemManagement.Path;
|
||||
using Lumina.Domain.Core.Aggregates.FileSystemManagement.FileSystemManagementAggregate.Services;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Services;
|
||||
using Mediator;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.Responses.FileSystemManagement.Path;
|
||||
using Lumina.Domain.Core.Aggregates.FileSystemManagement.FileSystemManagementAggregate.Services;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Services;
|
||||
using Mediator;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
+2
-2
@@ -2,8 +2,8 @@
|
||||
using ErrorOr;
|
||||
using Lumina.Application.Common.Mapping.FileSystemManagement.Thumbnails;
|
||||
using Lumina.Contracts.Responses.FileSystemManagement.Thumbnails;
|
||||
using Lumina.Domain.Core.Aggregates.FileSystemManagement.FileSystemManagementAggregate.Services;
|
||||
using Lumina.Domain.Core.Aggregates.FileSystemManagement.FileSystemManagementAggregate.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Services;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
|
||||
using Mediator;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Contracts.Enums.MediaLibrary;
|
||||
using Lumina.Contracts.Responses.MediaLibrary.Management;
|
||||
using Mediator;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Core.MediaLibrary.Management.Commands.AddLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Command for adding a media library.
|
||||
/// </summary>
|
||||
/// <param name="UserId">The Id of the user owning the media library.</param>
|
||||
/// <param name="LibraryType">The type of the media library.</param>
|
||||
/// <param name="ContentLocations">The file system paths of the directories where the media library elements are located.</param>
|
||||
/// <param name="Title">The title of the media library.</param>
|
||||
[DebuggerDisplay("Title: {Title}")]
|
||||
public record AddLibraryCommand(
|
||||
Guid UserId,
|
||||
string? Title,
|
||||
LibraryType? LibraryType,
|
||||
string[]? ContentLocations
|
||||
) : IRequest<ErrorOr<LibraryResponse>>;
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Application.Common.DataAccess.Repositories.MediaLibrary;
|
||||
using Lumina.Application.Common.DataAccess.UoW;
|
||||
using Lumina.Application.Common.Mapping.MediaLibrary.Management;
|
||||
using Lumina.Contracts.Entities.MediaLibrary.Management;
|
||||
using Lumina.Contracts.Enums.MediaLibrary;
|
||||
using Lumina.Contracts.Responses.MediaLibrary.Management;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate;
|
||||
using Mediator;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Core.MediaLibrary.Management.Commands.AddLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Handler for the command to add a media library.
|
||||
/// </summary>
|
||||
public class AddLibraryCommandHandler : IRequestHandler<AddLibraryCommand, ErrorOr<LibraryResponse>>
|
||||
{
|
||||
private readonly IUnitOfWork _unitOfWork;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="AddLibraryCommandHandler"/> class.
|
||||
/// </summary>
|
||||
/// <param name="unitOfWork">Injected unit of work for interacting with the data access layer repositories.</param>
|
||||
public AddLibraryCommandHandler(IUnitOfWork unitOfWork)
|
||||
{
|
||||
_unitOfWork = unitOfWork;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the command to add a media library.
|
||||
/// </summary>
|
||||
/// <param name="request">The request to be handled.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
/// <returns>
|
||||
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="LibraryResponse"/>, or an error message.
|
||||
/// </returns>
|
||||
public async ValueTask<ErrorOr<LibraryResponse>> Handle(AddLibraryCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
ErrorOr<Library> createLibraryResult = Library.Create(
|
||||
request.UserId,
|
||||
request.Title!,
|
||||
request.LibraryType ?? LibraryType.Other,
|
||||
request.ContentLocations!
|
||||
);
|
||||
|
||||
if (createLibraryResult.IsError)
|
||||
return createLibraryResult.Errors;
|
||||
|
||||
ILibraryRepository libraryRepository = _unitOfWork.GetRepository<ILibraryRepository>();
|
||||
LibraryEntity persistenceLibrary = createLibraryResult.Value.ToRepositoryEntity();
|
||||
ErrorOr<Created> insertLibraryResult = await libraryRepository.InsertAsync(persistenceLibrary, cancellationToken).ConfigureAwait(false);
|
||||
if (insertLibraryResult.IsError)
|
||||
return insertLibraryResult.Errors;
|
||||
await _unitOfWork.SaveChangesAsync(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return persistenceLibrary.ToResponse();
|
||||
}
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FluentValidation;
|
||||
using Lumina.Domain.Common.Errors;
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Core.MediaLibrary.Management.Commands.AddLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Validates the needed validation rules for <see cref="AddLibraryCommand"/>.
|
||||
/// </summary>
|
||||
public class AddLibraryCommandValidator : AbstractValidator<AddLibraryCommand>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="AddLibraryCommandValidator"/> class.
|
||||
/// </summary>
|
||||
public AddLibraryCommandValidator()
|
||||
{
|
||||
RuleFor(x => x.UserId)
|
||||
.NotEmpty().WithMessage(Errors.Library.UserIdCannotBeEmpty.Description)
|
||||
.Must(id => id != Guid.Empty).WithMessage(Errors.Library.UserIdCannotBeEmpty.Description);
|
||||
|
||||
RuleFor(x => x.LibraryType)
|
||||
.NotNull().WithMessage(Errors.Library.LibraryTypeCannotBeNull.Description)
|
||||
.IsInEnum().WithMessage(Errors.Library.UnknownLibraryType.Description);
|
||||
|
||||
RuleFor(x => x.ContentLocations)
|
||||
.NotNull().WithMessage(Errors.Library.PathsListCannotBeNull.Description)
|
||||
.NotEmpty().WithMessage(Errors.Library.PathsListCannotBeEmpty.Description);
|
||||
|
||||
RuleForEach(x => x.ContentLocations)
|
||||
.NotEmpty().WithMessage(Errors.FileSystemManagement.PathCannotBeEmpty.Description)
|
||||
.MaximumLength(260).WithMessage(Errors.FileSystemManagement.PathMustBeMaximum260CharactersLong.Description);
|
||||
|
||||
RuleFor(x => x.Title)
|
||||
.NotEmpty().WithMessage(Errors.Library.TitleCannotBeEmpty.Description)
|
||||
.MaximumLength(255).WithMessage(Errors.Library.TitleMustBeMaximum255CharactersLong.Description);
|
||||
}
|
||||
}
|
||||
+4
-4
@@ -1,16 +1,16 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Contracts.Entities.MediaContributors;
|
||||
using Lumina.Contracts.Entities.WrittenContentLibrary;
|
||||
using Lumina.Contracts.Entities.WrittenContentLibrary.BookLibrary;
|
||||
using Lumina.Contracts.Entities.MediaLibrary.WrittenContentLibrary;
|
||||
using Lumina.Contracts.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary;
|
||||
using Lumina.Contracts.Enums.BookLibrary;
|
||||
using Lumina.Contracts.Responses.WrittenContentLibrary.BookLibrary.Books;
|
||||
using Lumina.Contracts.Responses.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
|
||||
using Mediator;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Core.WrittenContentLibrary.BooksLibrary.Books.Commands.AddBook;
|
||||
namespace Lumina.Application.Core.MediaLibrary.WrittenContentLibrary.BooksLibrary.Books.Commands.AddBook;
|
||||
|
||||
/// <summary>
|
||||
/// Command for adding a book.
|
||||
+9
-9
@@ -2,17 +2,17 @@
|
||||
using ErrorOr;
|
||||
using Lumina.Application.Common.DataAccess.Repositories.Books;
|
||||
using Lumina.Application.Common.DataAccess.UoW;
|
||||
using Lumina.Application.Common.Mapping.WrittenContentLibrary.BookLibrary.Books;
|
||||
using Lumina.Application.Common.Mapping.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
|
||||
using Lumina.Contracts.Entities.MediaContributors;
|
||||
using Lumina.Contracts.Entities.WrittenContentLibrary.BookLibrary;
|
||||
using Lumina.Contracts.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary;
|
||||
using Lumina.Contracts.Enums.BookLibrary;
|
||||
using Lumina.Contracts.Responses.WrittenContentLibrary.BookLibrary.Books;
|
||||
using Lumina.Contracts.Responses.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Common.ValueObjects.Metadata;
|
||||
using Lumina.Domain.Core.Aggregates.MediaContributor.MediaContributorAggregate.ValueObjects;
|
||||
using Lumina.Domain.Core.Aggregates.WrittenContentLibrary.BookLibraryAggregate;
|
||||
using Lumina.Domain.Core.Aggregates.WrittenContentLibrary.BookLibraryAggregate.Entities;
|
||||
using Lumina.Domain.Core.Aggregates.WrittenContentLibrary.BookLibraryAggregate.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.MediaContributorBoundedContext.MediaContributorAggregate.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate;
|
||||
using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.Entities;
|
||||
using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.ValueObjects;
|
||||
using Mediator;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -21,7 +21,7 @@ using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Core.WrittenContentLibrary.BooksLibrary.Books.Commands.AddBook;
|
||||
namespace Lumina.Application.Core.MediaLibrary.WrittenContentLibrary.BooksLibrary.Books.Commands.AddBook;
|
||||
|
||||
/// <summary>
|
||||
/// Handler for the command to add a book.
|
||||
@@ -45,7 +45,7 @@ public class AddBookCommandHandler : IRequestHandler<AddBookCommand, ErrorOr<Boo
|
||||
/// <param name="request">The request to be handled.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
/// <returns>
|
||||
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="Book"/>, or an error message.
|
||||
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="BookResponse"/>, or an error message.
|
||||
/// </returns>
|
||||
public async ValueTask<ErrorOr<BookResponse>> Handle(AddBookCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
+1
-1
@@ -4,7 +4,7 @@ using Lumina.Contracts.Enums.BookLibrary;
|
||||
using Lumina.Domain.Common.Errors;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Core.WrittenContentLibrary.BooksLibrary.Books.Commands.AddBook;
|
||||
namespace Lumina.Application.Core.MediaLibrary.WrittenContentLibrary.BooksLibrary.Books.Commands.AddBook;
|
||||
|
||||
/// <summary>
|
||||
/// Validates the needed validation rules for <see cref="AddBookCommand"/>.
|
||||
+2
-2
@@ -1,11 +1,11 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Contracts.Responses.WrittenContentLibrary.BookLibrary.Books;
|
||||
using Lumina.Contracts.Responses.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
|
||||
using Mediator;
|
||||
using System.Collections.Generic;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Core.WrittenContentLibrary.BooksLibrary.Books.Queries.GetBooks;
|
||||
namespace Lumina.Application.Core.MediaLibrary.WrittenContentLibrary.BooksLibrary.Books.Queries.GetBooks;
|
||||
|
||||
/// <summary>
|
||||
/// Query for getting all books.
|
||||
+4
-4
@@ -2,16 +2,16 @@
|
||||
using ErrorOr;
|
||||
using Lumina.Application.Common.DataAccess.Repositories.Books;
|
||||
using Lumina.Application.Common.DataAccess.UoW;
|
||||
using Lumina.Application.Common.Mapping.WrittenContentLibrary.BookLibrary.Books;
|
||||
using Lumina.Contracts.Entities.WrittenContentLibrary.BookLibrary;
|
||||
using Lumina.Contracts.Responses.WrittenContentLibrary.BookLibrary.Books;
|
||||
using Lumina.Application.Common.Mapping.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
|
||||
using Lumina.Contracts.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary;
|
||||
using Lumina.Contracts.Responses.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
|
||||
using Mediator;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Core.WrittenContentLibrary.BooksLibrary.Books.Queries.GetBooks;
|
||||
namespace Lumina.Application.Core.MediaLibrary.WrittenContentLibrary.BooksLibrary.Books.Queries.GetBooks;
|
||||
|
||||
/// <summary>
|
||||
/// Handler for the query to get all books.
|
||||
Reference in new issue
Block a user