diff --git a/README.md b/README.md
index e362d9bc..b59a2f4b 100644
--- a/README.md
+++ b/README.md
@@ -36,9 +36,10 @@ Most icons were taken from [Lyra Icon Theme](https://github.com/yeyushengfan258/
Several icons used in this project were adapted from icons sourced from [svgrepo](https://www.svgrepo.com/).
-- [`toggle-thumbnails.svg`](https://www.svgrepo.com/svg/370469/page-image) (Public Domain license)
+- [`toggle-thumbnails.svg`](https://www.svgrepo.com/svg/370469/page-image) (Public Domain License)
- [`toggle-hidden.svg`](https://www.svgrepo.com/svg/470389/hidden) (MIT License)
- [`delete.svg`](https://www.svgrepo.com/svg/488148/delete) (MIT License)
+- [`add-file.svg`](https://www.svgrepo.com/svg/467914/add-file-8) (Public Domain License)
- [`add-directory.svg`](https://www.svgrepo.com/svg/488040/add-folder) (MIT License)
- [`information.svg`](https://www.svgrepo.com/svg/403685/information) (MIT License)
- [`question.svg`](https://www.svgrepo.com/svg/486470/question-filled) (MIT License)
diff --git a/src/Lumina.Application/Common/DataAccess/Entities/MediaLibrary/Management/LibraryEntity.cs b/src/Lumina.Application/Common/DataAccess/Entities/MediaLibrary/Management/LibraryEntity.cs
index 9c9bf2e3..9522bcbf 100644
--- a/src/Lumina.Application/Common/DataAccess/Entities/MediaLibrary/Management/LibraryEntity.cs
+++ b/src/Lumina.Application/Common/DataAccess/Entities/MediaLibrary/Management/LibraryEntity.cs
@@ -30,6 +30,11 @@ public class LibraryEntity : IStorageEntity, IAuditableEntity
///
public required string Title { get; set; }
+ ///
+ /// Gets or sets the path of the image file used as the cover for the library.
+ ///
+ public string? CoverImage { get; set; }
+
///
/// Gets or sets the type of the media library.
///
diff --git a/src/Lumina.Application/Common/Mapping/MediaLibrary/Management/AddMediaLibraryRequestMapping.cs b/src/Lumina.Application/Common/Mapping/MediaLibrary/Management/AddMediaLibraryRequestMapping.cs
index 94a05159..6ce350b2 100644
--- a/src/Lumina.Application/Common/Mapping/MediaLibrary/Management/AddMediaLibraryRequestMapping.cs
+++ b/src/Lumina.Application/Common/Mapping/MediaLibrary/Management/AddMediaLibraryRequestMapping.cs
@@ -17,15 +17,14 @@ public static class AddMediaLibraryRequestMapping
/// Converts to .
///
/// The request to be converted.
- /// The Id of the user owning the media library.
/// The converted command.
- public static AddLibraryCommand ToCommand(this AddLibraryRequest request, Guid userId)
+ public static AddLibraryCommand ToCommand(this AddLibraryRequest request)
{
return new AddLibraryCommand(
- userId,
request.Title,
request.LibraryType,
- request.ContentLocations
+ request.ContentLocations,
+ request.CoverImage
);
}
}
diff --git a/src/Lumina.Application/Common/Mapping/MediaLibrary/Management/LibraryEntityMapping.cs b/src/Lumina.Application/Common/Mapping/MediaLibrary/Management/LibraryEntityMapping.cs
index 89e9ae60..8b18f905 100644
--- a/src/Lumina.Application/Common/Mapping/MediaLibrary/Management/LibraryEntityMapping.cs
+++ b/src/Lumina.Application/Common/Mapping/MediaLibrary/Management/LibraryEntityMapping.cs
@@ -24,6 +24,7 @@ public static class LibraryEntityMapping
repositoryEntity.Title,
repositoryEntity.LibraryType,
repositoryEntity.ContentLocations.Select(location => location.Path).ToList(),
+ repositoryEntity.CoverImage,
repositoryEntity.CreatedOnUtc,
repositoryEntity.UpdatedOnUtc
);
diff --git a/src/Lumina.Application/Common/Mapping/MediaLibrary/Management/LibraryMapping.cs b/src/Lumina.Application/Common/Mapping/MediaLibrary/Management/LibraryMapping.cs
index 47fcf587..03f8016b 100644
--- a/src/Lumina.Application/Common/Mapping/MediaLibrary/Management/LibraryMapping.cs
+++ b/src/Lumina.Application/Common/Mapping/MediaLibrary/Management/LibraryMapping.cs
@@ -26,6 +26,7 @@ public static class LibraryMapping
LibraryType = domainEntity.LibraryType,
UserId = domainEntity.UserId.Value,
ContentLocations = domainEntity.ContentLocations.Select(path => new LibraryContentLocationEntity() { Path = path.Path }).ToList(),
+ CoverImage = domainEntity.CoverImage,
CreatedOnUtc = domainEntity.CreatedOnUtc,
CreatedBy = Guid.Empty,
UpdatedOnUtc = domainEntity.UpdatedOnUtc.HasValue ? domainEntity.UpdatedOnUtc : null,
diff --git a/src/Lumina.Application/Common/Mapping/MediaLibrary/Management/UpdateLibraryRequestMapping.cs b/src/Lumina.Application/Common/Mapping/MediaLibrary/Management/UpdateLibraryRequestMapping.cs
index 2fa3a323..92aa3f64 100644
--- a/src/Lumina.Application/Common/Mapping/MediaLibrary/Management/UpdateLibraryRequestMapping.cs
+++ b/src/Lumina.Application/Common/Mapping/MediaLibrary/Management/UpdateLibraryRequestMapping.cs
@@ -15,17 +15,16 @@ public static class UpdateLibraryRequestMapping
/// Converts to .
///
/// The request to be converted.
- /// The Id of the user making the request to update the media library.
/// The converted command.
- public static UpdateLibraryCommand ToCommand(this UpdateLibraryRequest request, Guid userId)
+ public static UpdateLibraryCommand ToCommand(this UpdateLibraryRequest request)
{
return new UpdateLibraryCommand(
request.Id,
request.UserId,
- userId,
request.Title,
request.LibraryType,
- request.ContentLocations
+ request.ContentLocations,
+ request.CoverImage
);
}
}
diff --git a/src/Lumina.Application/Core/MediaLibrary/Management/Commands/AddLibrary/AddLibraryCommand.cs b/src/Lumina.Application/Core/MediaLibrary/Management/Commands/AddLibrary/AddLibraryCommand.cs
index 3afa19d7..ad8838f9 100644
--- a/src/Lumina.Application/Core/MediaLibrary/Management/Commands/AddLibrary/AddLibraryCommand.cs
+++ b/src/Lumina.Application/Core/MediaLibrary/Management/Commands/AddLibrary/AddLibraryCommand.cs
@@ -11,14 +11,14 @@ namespace Lumina.Application.Core.MediaLibrary.Management.Commands.AddLibrary;
///
/// Command for adding a media library.
///
-/// The Id of the user owning the media library.
+/// The title of the media library.
/// The type of the media library.
/// The file system paths of the directories where the media library elements are located.
-/// The title of the media library.
+/// The path of the image file used as the cover for the library.
[DebuggerDisplay("Title: {Title}")]
public record AddLibraryCommand(
- Guid UserId,
string? Title,
string? LibraryType,
- string[]? ContentLocations
+ string[]? ContentLocations,
+ string? CoverImage
) : IRequest>;
diff --git a/src/Lumina.Application/Core/MediaLibrary/Management/Commands/AddLibrary/AddLibraryCommandHandler.cs b/src/Lumina.Application/Core/MediaLibrary/Management/Commands/AddLibrary/AddLibraryCommandHandler.cs
index d6d8c7ff..961e2db2 100644
--- a/src/Lumina.Application/Core/MediaLibrary/Management/Commands/AddLibrary/AddLibraryCommandHandler.cs
+++ b/src/Lumina.Application/Core/MediaLibrary/Management/Commands/AddLibrary/AddLibraryCommandHandler.cs
@@ -4,6 +4,7 @@ using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management;
using Lumina.Application.Common.DataAccess.Repositories.MediaLibrary;
using Lumina.Application.Common.DataAccess.UoW;
using Lumina.Application.Common.Errors;
+using Lumina.Application.Common.Infrastructure.Authentication;
using Lumina.Application.Common.Mapping.MediaLibrary.Management;
using Lumina.Contracts.Responses.MediaLibrary.Management;
using Lumina.Domain.Common.Enums.MediaLibrary;
@@ -22,14 +23,17 @@ namespace Lumina.Application.Core.MediaLibrary.Management.Commands.AddLibrary;
public class AddLibraryCommandHandler : IRequestHandler>
{
private readonly IUnitOfWork _unitOfWork;
+ private readonly ICurrentUserService _currentUserService;
///
/// Initializes a new instance of the class.
///
/// Injected unit of work for interacting with the data access layer repositories.
- public AddLibraryCommandHandler(IUnitOfWork unitOfWork)
+ /// Injected service to retrieve the current user information.
+ public AddLibraryCommandHandler(IUnitOfWork unitOfWork, ICurrentUserService currentUserService)
{
_unitOfWork = unitOfWork;
+ _currentUserService = currentUserService;
}
///
@@ -44,10 +48,11 @@ public class AddLibraryCommandHandler : IRequestHandler createLibraryResult = Library.Create(
- request.UserId,
+ _currentUserService.UserId!.Value,
request.Title!,
Enum.Parse(request.LibraryType!),
- request.ContentLocations!
+ request.ContentLocations!,
+ request.CoverImage
);
if (createLibraryResult.IsError)
diff --git a/src/Lumina.Application/Core/MediaLibrary/Management/Commands/AddLibrary/AddLibraryCommandValidator.cs b/src/Lumina.Application/Core/MediaLibrary/Management/Commands/AddLibrary/AddLibraryCommandValidator.cs
index af820f8a..21453bb6 100644
--- a/src/Lumina.Application/Core/MediaLibrary/Management/Commands/AddLibrary/AddLibraryCommandValidator.cs
+++ b/src/Lumina.Application/Core/MediaLibrary/Management/Commands/AddLibrary/AddLibraryCommandValidator.cs
@@ -17,10 +17,6 @@ public class AddLibraryCommandValidator : AbstractValidator
///
public AddLibraryCommandValidator()
{
- RuleFor(x => x.UserId)
- .NotEmpty().WithMessage(Errors.Users.UserIdCannotBeEmpty.Description)
- .Must(id => id != Guid.Empty).WithMessage(Errors.Users.UserIdCannotBeEmpty.Description);
-
RuleFor(x => x.LibraryType)
.NotNull().WithMessage(Errors.Library.LibraryTypeCannotBeNull.Description)
.Must(x => Enum.TryParse(x, out _))
diff --git a/src/Lumina.Application/Core/MediaLibrary/Management/Commands/UpdateLibrary/UpdateLibraryCommand.cs b/src/Lumina.Application/Core/MediaLibrary/Management/Commands/UpdateLibrary/UpdateLibraryCommand.cs
index 530d8b68..e3b37d1d 100644
--- a/src/Lumina.Application/Core/MediaLibrary/Management/Commands/UpdateLibrary/UpdateLibraryCommand.cs
+++ b/src/Lumina.Application/Core/MediaLibrary/Management/Commands/UpdateLibrary/UpdateLibraryCommand.cs
@@ -1,6 +1,5 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
-using Lumina.Domain.Common.Enums.MediaLibrary;
using Lumina.Contracts.Responses.MediaLibrary.Management;
using Mediator;
using System;
@@ -14,16 +13,16 @@ namespace Lumina.Application.Core.MediaLibrary.Management.Commands.UpdateLibrary
///
/// The Id of the media library.
/// The Id of the user owning the media library.
-/// The Id of the user making the request to update the media library.
+/// The title of the media library.
/// The type of the media library.
/// The file system paths of the directories where the media library elements are located.
-/// The title of the media library.
+/// The path of the image file used as the cover for the library.
[DebuggerDisplay("Title: {Title}")]
public record UpdateLibraryCommand(
Guid Id,
Guid OwnerId,
- Guid CurrentUserId,
string? Title,
string? LibraryType,
- string[]? ContentLocations
+ string[]? ContentLocations,
+ string? CoverImage
) : IRequest>;
diff --git a/src/Lumina.Application/Core/MediaLibrary/Management/Commands/UpdateLibrary/UpdateLibraryCommandHandler.cs b/src/Lumina.Application/Core/MediaLibrary/Management/Commands/UpdateLibrary/UpdateLibraryCommandHandler.cs
index eeea382b..9d96ad7e 100644
--- a/src/Lumina.Application/Core/MediaLibrary/Management/Commands/UpdateLibrary/UpdateLibraryCommandHandler.cs
+++ b/src/Lumina.Application/Core/MediaLibrary/Management/Commands/UpdateLibrary/UpdateLibraryCommandHandler.cs
@@ -3,6 +3,8 @@ using ErrorOr;
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management;
using Lumina.Application.Common.DataAccess.Repositories.MediaLibrary;
using Lumina.Application.Common.DataAccess.UoW;
+using Lumina.Application.Common.Infrastructure.Authentication;
+using Lumina.Application.Common.Infrastructure.Authorization;
using Lumina.Application.Common.Mapping.MediaLibrary.Management;
using Lumina.Contracts.Responses.MediaLibrary.Management;
using Lumina.Domain.Common.Enums.MediaLibrary;
@@ -24,13 +26,19 @@ namespace Lumina.Application.Core.MediaLibrary.Management.Commands.UpdateLibrary
public class UpdateLibraryCommandHandler : IRequestHandler>
{
private readonly IUnitOfWork _unitOfWork;
+ private readonly ICurrentUserService _currentUserService;
+ private readonly IAuthorizationService _authorizationService;
///
/// Initializes a new instance of the class.
///
+ /// Injected service for authorization related functionality.
+ /// Injected service to retrieve the current user information.
/// Injected unit of work for interacting with the data access layer repositories.
- public UpdateLibraryCommandHandler(IUnitOfWork unitOfWork)
+ public UpdateLibraryCommandHandler(IAuthorizationService authorizationService, ICurrentUserService currentUserService, IUnitOfWork unitOfWork)
{
+ _authorizationService = authorizationService;
+ _currentUserService = currentUserService;
_unitOfWork = unitOfWork;
}
@@ -52,7 +60,7 @@ public class UpdateLibraryCommandHandler : IRequestHandler(request.LibraryType!),
- request.ContentLocations!
+ request.ContentLocations!,
+ request.CoverImage
);
if (createLibraryResult.IsError)
return createLibraryResult.Errors;
diff --git a/src/Lumina.Application/Core/MediaLibrary/Management/Commands/UpdateLibrary/UpdateLibraryCommandValidator.cs b/src/Lumina.Application/Core/MediaLibrary/Management/Commands/UpdateLibrary/UpdateLibraryCommandValidator.cs
index e72dd2aa..3318eb0b 100644
--- a/src/Lumina.Application/Core/MediaLibrary/Management/Commands/UpdateLibrary/UpdateLibraryCommandValidator.cs
+++ b/src/Lumina.Application/Core/MediaLibrary/Management/Commands/UpdateLibrary/UpdateLibraryCommandValidator.cs
@@ -21,10 +21,6 @@ public class UpdateLibraryCommandValidator : AbstractValidator id != Guid.Empty).WithMessage(Errors.Library.LibraryIdCannotBeEmpty.Description);
- RuleFor(x => x.CurrentUserId)
- .NotEmpty().WithMessage(Errors.Users.UserIdCannotBeEmpty.Description)
- .Must(id => id != Guid.Empty).WithMessage(Errors.Users.UserIdCannotBeEmpty.Description);
-
RuleFor(x => x.OwnerId)
.NotEmpty().WithMessage(Errors.Users.UserIdCannotBeEmpty.Description)
.Must(id => id != Guid.Empty).WithMessage(Errors.Users.UserIdCannotBeEmpty.Description);
diff --git a/src/Lumina.Contracts/Requests/MediaLibrary/Management/AddLibraryRequest.cs b/src/Lumina.Contracts/Requests/MediaLibrary/Management/AddLibraryRequest.cs
index 6865ccf8..0111445f 100644
--- a/src/Lumina.Contracts/Requests/MediaLibrary/Management/AddLibraryRequest.cs
+++ b/src/Lumina.Contracts/Requests/MediaLibrary/Management/AddLibraryRequest.cs
@@ -10,9 +10,11 @@ namespace Lumina.Contracts.Requests.MediaLibrary.Management;
/// The title of the media library. Required.
/// The type of the media library. Required.
/// The file system paths of the directories where the media library elements are located. Required.
+/// The path of the image file used as the cover for the library. Optional.
[DebuggerDisplay("Title: {Title}")]
public record AddLibraryRequest(
string? Title,
string? LibraryType,
- string[]? ContentLocations
+ string[]? ContentLocations,
+ string? CoverImage
);
diff --git a/src/Lumina.Contracts/Requests/MediaLibrary/Management/UpdateLibraryRequest.cs b/src/Lumina.Contracts/Requests/MediaLibrary/Management/UpdateLibraryRequest.cs
index 9f2dafbc..e4b864ac 100644
--- a/src/Lumina.Contracts/Requests/MediaLibrary/Management/UpdateLibraryRequest.cs
+++ b/src/Lumina.Contracts/Requests/MediaLibrary/Management/UpdateLibraryRequest.cs
@@ -2,6 +2,7 @@
using Lumina.Domain.Common.Enums.MediaLibrary;
using System;
using System.Diagnostics;
+using System.Runtime.InteropServices;
#endregion
namespace Lumina.Contracts.Requests.MediaLibrary.Management;
@@ -14,11 +15,13 @@ namespace Lumina.Contracts.Requests.MediaLibrary.Management;
/// The title of the media library. Required.
/// The type of the media library. Required.
/// The file system paths of the directories where the media library elements are located. Required.
+/// The path of the image file used as the cover for the library. Optional.
[DebuggerDisplay("Title: {Title}")]
public record class UpdateLibraryRequest(
Guid Id,
Guid UserId,
string? Title,
string? LibraryType,
- string[]? ContentLocations
+ string[]? ContentLocations,
+ string? CoverImage
);
diff --git a/src/Lumina.Contracts/Responses/MediaLibrary/Management/LibraryResponse.cs b/src/Lumina.Contracts/Responses/MediaLibrary/Management/LibraryResponse.cs
index b6e32eb9..a4ab81ff 100644
--- a/src/Lumina.Contracts/Responses/MediaLibrary/Management/LibraryResponse.cs
+++ b/src/Lumina.Contracts/Responses/MediaLibrary/Management/LibraryResponse.cs
@@ -15,6 +15,7 @@ namespace Lumina.Contracts.Responses.MediaLibrary.Management;
/// The title of the media library.
/// The type of the media library.
/// The file system paths of the directories where the media library elements are located.
+/// The path of the image file used as the cover for the library.
/// The date and time when the library was created.
/// The optional date and time when the library was updated.
[DebuggerDisplay("Title: {Title}")]
@@ -24,6 +25,7 @@ public record LibraryResponse(
string Title,
LibraryType LibraryType,
List ContentLocations,
+ string? CoverImage,
DateTime CreatedOnUtc,
DateTime? UpdatedOnUtc
);
diff --git a/src/Lumina.DataAccess/Common/Configuration/LibraryConfiguration.cs b/src/Lumina.DataAccess/Common/Configuration/LibraryConfiguration.cs
index bf5d8d63..20de8a2d 100644
--- a/src/Lumina.DataAccess/Common/Configuration/LibraryConfiguration.cs
+++ b/src/Lumina.DataAccess/Common/Configuration/LibraryConfiguration.cs
@@ -28,12 +28,17 @@ public class LibraryConfiguration : IEntityTypeConfiguration
.IsRequired()
.HasMaxLength(255)
.HasColumnOrder(1);
-
+
builder.Property(library => library.LibraryType)
.IsRequired()
.HasConversion()
.HasColumnOrder(2);
+ builder.Property(library => library.CoverImage)
+ .HasMaxLength(255)
+ .HasDefaultValue(null)
+ .HasColumnOrder(3);
+
// one user with many libraries
builder.HasOne(library => library.User)
.WithMany(user => user.Libraries)
diff --git a/src/Lumina.DataAccess/Common/Migrations/20250103134553_AddMediaLibraryCoverImageColumn.Designer.cs b/src/Lumina.DataAccess/Common/Migrations/20250103134553_AddMediaLibraryCoverImageColumn.Designer.cs
new file mode 100644
index 00000000..6afe8bf7
--- /dev/null
+++ b/src/Lumina.DataAccess/Common/Migrations/20250103134553_AddMediaLibraryCoverImageColumn.Designer.cs
@@ -0,0 +1,714 @@
+//
+using System;
+using Lumina.DataAccess.Core.UoW;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+
+#nullable disable
+
+namespace Lumina.DataAccess.Common.Migrations
+{
+ [DbContext(typeof(LuminaDbContext))]
+ [Migration("20250103134553_AddMediaLibraryCoverImageColumn")]
+ partial class AddMediaLibraryCoverImageColumn
+ {
+ ///
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder.HasAnnotation("ProductVersion", "9.0.0");
+
+ modelBuilder.Entity("BookGenres", b =>
+ {
+ b.Property("BookId")
+ .HasColumnType("TEXT");
+
+ b.Property("GenreId")
+ .HasColumnType("TEXT");
+
+ b.HasKey("BookId", "GenreId");
+
+ b.HasIndex("GenreId");
+
+ b.ToTable("BookGenres", (string)null);
+ });
+
+ modelBuilder.Entity("BookTags", b =>
+ {
+ b.Property("BookId")
+ .HasColumnType("TEXT");
+
+ b.Property("TagId")
+ .HasColumnType("TEXT");
+
+ b.HasKey("BookId", "TagId");
+
+ b.HasIndex("TagId");
+
+ b.ToTable("BookTags", (string)null);
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.PermissionEntity", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("TEXT")
+ .HasColumnOrder(0);
+
+ b.Property("CreatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(4);
+
+ b.Property("CreatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(3);
+
+ b.Property("PermissionName")
+ .IsRequired()
+ .HasMaxLength(100)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(1);
+
+ b.Property("UpdatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(6);
+
+ b.Property("UpdatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(5);
+
+ b.HasKey("Id");
+
+ b.ToTable("Permissions", (string)null);
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.RoleEntity", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("TEXT")
+ .HasColumnOrder(0);
+
+ b.Property("CreatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(4);
+
+ b.Property("CreatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(3);
+
+ b.Property("RoleName")
+ .IsRequired()
+ .HasMaxLength(100)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(1);
+
+ b.Property("UpdatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(6);
+
+ b.Property("UpdatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(5);
+
+ b.HasKey("Id");
+
+ b.ToTable("Roles", (string)null);
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.RolePermissionEntity", b =>
+ {
+ b.Property("RoleId")
+ .HasColumnType("TEXT");
+
+ b.Property("PermissionId")
+ .HasColumnType("TEXT");
+
+ b.Property("CreatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(2);
+
+ b.Property("CreatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(1);
+
+ b.Property("UpdatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(4);
+
+ b.Property("UpdatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(3);
+
+ b.HasKey("RoleId", "PermissionId");
+
+ b.HasIndex("PermissionId");
+
+ b.HasIndex("RoleId", "PermissionId")
+ .IsUnique();
+
+ b.ToTable("RolePermissions", (string)null);
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.UserPermissionEntity", b =>
+ {
+ b.Property("UserId")
+ .HasColumnType("TEXT");
+
+ b.Property("PermissionId")
+ .HasColumnType("TEXT");
+
+ b.Property("CreatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(2);
+
+ b.Property("CreatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(1);
+
+ b.Property("UpdatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(4);
+
+ b.Property("UpdatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(3);
+
+ b.HasKey("UserId", "PermissionId");
+
+ b.HasIndex("PermissionId");
+
+ b.HasIndex("UserId", "PermissionId")
+ .IsUnique();
+
+ b.ToTable("UserPermissions", (string)null);
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.UserRoleEntity", b =>
+ {
+ b.Property("UserId")
+ .HasColumnType("TEXT");
+
+ b.Property("CreatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(2);
+
+ b.Property("CreatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(1);
+
+ b.Property("RoleId")
+ .HasColumnType("TEXT");
+
+ b.Property("UpdatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(4);
+
+ b.Property("UpdatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(3);
+
+ b.HasKey("UserId");
+
+ b.HasIndex("RoleId");
+
+ b.HasIndex("UserId", "RoleId")
+ .IsUnique();
+
+ b.ToTable("UserRoles", (string)null);
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Common.GenreEntity", b =>
+ {
+ b.Property("Name")
+ .HasMaxLength(50)
+ .HasColumnType("TEXT");
+
+ b.HasKey("Name");
+
+ b.ToTable("Genres", (string)null);
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Common.TagEntity", b =>
+ {
+ b.Property("Name")
+ .HasMaxLength(50)
+ .HasColumnType("TEXT");
+
+ b.HasKey("Name");
+
+ b.ToTable("Tags", (string)null);
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.LibraryEntity", b =>
+ {
+ b.Property("Id")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(0);
+
+ b.Property("CoverImage")
+ .HasMaxLength(255)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(3);
+
+ b.Property("CreatedBy")
+ .HasColumnType("TEXT");
+
+ b.Property("CreatedOnUtc")
+ .HasColumnType("TEXT");
+
+ b.Property("LibraryType")
+ .IsRequired()
+ .HasColumnType("TEXT")
+ .HasColumnOrder(2);
+
+ b.Property("Title")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(1);
+
+ b.Property("UpdatedBy")
+ .HasColumnType("TEXT");
+
+ b.Property("UpdatedOnUtc")
+ .HasColumnType("TEXT");
+
+ b.Property("UserId")
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.HasIndex("UserId");
+
+ b.ToTable("Libraries", (string)null);
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary.BookEntity", b =>
+ {
+ b.Property("Id")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(0);
+
+ b.Property("ASIN")
+ .HasMaxLength(10)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(21);
+
+ b.Property("AppleBooksId")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(29);
+
+ b.Property("BarnesAndNobleId")
+ .HasMaxLength(10)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(28);
+
+ b.Property("CreatedBy")
+ .HasColumnType("TEXT");
+
+ b.Property("CreatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(30);
+
+ b.Property("Description")
+ .HasMaxLength(2000)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(3);
+
+ b.Property("Edition")
+ .HasMaxLength(50)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(19);
+
+ b.Property("Format")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(18);
+
+ b.Property("GoodreadsId")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(22);
+
+ b.Property("GoogleBooksId")
+ .HasMaxLength(12)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(27);
+
+ b.Property("LCCN")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(23);
+
+ b.Property("LanguageCode")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(10);
+
+ b.Property("LanguageName")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(11);
+
+ b.Property("LanguageNativeName")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(12);
+
+ b.Property("LibraryThingId")
+ .HasMaxLength(50)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(26);
+
+ b.Property("OCLCNumber")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(24);
+
+ b.Property("OpenLibraryId")
+ .HasMaxLength(50)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(25);
+
+ b.Property("OriginalLanguageCode")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(13);
+
+ b.Property("OriginalLanguageName")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(14);
+
+ b.Property("OriginalLanguageNativeName")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(15);
+
+ b.Property("OriginalReleaseDate")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(4);
+
+ b.Property("OriginalReleaseYear")
+ .HasColumnType("INTEGER")
+ .HasColumnOrder(5);
+
+ b.Property("OriginalTitle")
+ .HasMaxLength(255)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(2);
+
+ b.Property("PageCount")
+ .HasColumnType("INTEGER")
+ .HasColumnOrder(17);
+
+ b.Property("Publisher")
+ .HasMaxLength(100)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(16);
+
+ b.Property("ReReleaseDate")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(6);
+
+ b.Property("ReReleaseYear")
+ .HasColumnType("INTEGER")
+ .HasColumnOrder(7);
+
+ b.Property("ReleaseCountry")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(8);
+
+ b.Property("ReleaseVersion")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(9);
+
+ b.Property("Title")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(1);
+
+ b.Property("UpdatedBy")
+ .HasColumnType("TEXT");
+
+ b.Property("UpdatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(31);
+
+ b.Property("VolumeNumber")
+ .HasColumnType("INTEGER")
+ .HasColumnOrder(20);
+
+ b.HasKey("Id");
+
+ b.ToTable("Books", (string)null);
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.UsersManagement.UserEntity", b =>
+ {
+ b.Property("Id")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(0);
+
+ b.Property("CreatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(7);
+
+ b.Property("CreatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(6);
+
+ b.Property("Password")
+ .IsRequired()
+ .HasColumnType("TEXT")
+ .HasColumnOrder(2);
+
+ b.Property("TempPassword")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(3);
+
+ b.Property("TempPasswordCreated")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(5);
+
+ b.Property("TotpSecret")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(4);
+
+ b.Property("UpdatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(9);
+
+ b.Property("UpdatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(8);
+
+ b.Property("Username")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(1);
+
+ b.HasKey("Id");
+
+ b.HasIndex("Username")
+ .IsUnique();
+
+ b.ToTable("Users", (string)null);
+ });
+
+ modelBuilder.Entity("BookGenres", b =>
+ {
+ b.HasOne("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary.BookEntity", null)
+ .WithMany()
+ .HasForeignKey("BookId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("Lumina.Application.Common.DataAccess.Entities.Common.GenreEntity", null)
+ .WithMany()
+ .HasForeignKey("GenreId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("BookTags", b =>
+ {
+ b.HasOne("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary.BookEntity", null)
+ .WithMany()
+ .HasForeignKey("BookId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("Lumina.Application.Common.DataAccess.Entities.Common.TagEntity", null)
+ .WithMany()
+ .HasForeignKey("TagId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.RolePermissionEntity", b =>
+ {
+ b.HasOne("Lumina.Application.Common.DataAccess.Entities.Authorization.PermissionEntity", "Permission")
+ .WithMany("RolePermissions")
+ .HasForeignKey("PermissionId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("Lumina.Application.Common.DataAccess.Entities.Authorization.RoleEntity", "Role")
+ .WithMany("RolePermissions")
+ .HasForeignKey("RoleId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Permission");
+
+ b.Navigation("Role");
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.UserPermissionEntity", b =>
+ {
+ b.HasOne("Lumina.Application.Common.DataAccess.Entities.Authorization.PermissionEntity", "Permission")
+ .WithMany("UserPermissions")
+ .HasForeignKey("PermissionId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("Lumina.Application.Common.DataAccess.Entities.UsersManagement.UserEntity", "User")
+ .WithMany("UserPermissions")
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Permission");
+
+ b.Navigation("User");
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.UserRoleEntity", b =>
+ {
+ b.HasOne("Lumina.Application.Common.DataAccess.Entities.Authorization.RoleEntity", "Role")
+ .WithMany("UserRoles")
+ .HasForeignKey("RoleId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("Lumina.Application.Common.DataAccess.Entities.UsersManagement.UserEntity", "User")
+ .WithOne("UserRole")
+ .HasForeignKey("Lumina.Application.Common.DataAccess.Entities.Authorization.UserRoleEntity", "UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Role");
+
+ b.Navigation("User");
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.LibraryEntity", b =>
+ {
+ b.HasOne("Lumina.Application.Common.DataAccess.Entities.UsersManagement.UserEntity", "User")
+ .WithMany("Libraries")
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.OwnsMany("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.LibraryContentLocationEntity", "ContentLocations", b1 =>
+ {
+ b1.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("TEXT");
+
+ b1.Property("LibraryId")
+ .HasColumnType("TEXT");
+
+ b1.Property("Path")
+ .IsRequired()
+ .HasMaxLength(260)
+ .HasColumnType("TEXT")
+ .HasColumnName("Path");
+
+ b1.HasKey("Id");
+
+ b1.HasIndex("LibraryId");
+
+ b1.ToTable("LibraryContentLocations", (string)null);
+
+ b1.WithOwner()
+ .HasForeignKey("LibraryId");
+ });
+
+ b.Navigation("ContentLocations");
+
+ b.Navigation("User");
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary.BookEntity", b =>
+ {
+ b.OwnsMany("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary.BookRatingEntity", "Ratings", b1 =>
+ {
+ b1.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("TEXT");
+
+ b1.Property("BookId")
+ .HasColumnType("TEXT");
+
+ b1.Property("MaxValue")
+ .HasColumnType("decimal(3,2)");
+
+ b1.Property("Source")
+ .IsRequired()
+ .HasMaxLength(50)
+ .HasColumnType("TEXT");
+
+ b1.Property("Value")
+ .HasColumnType("decimal(3,2)");
+
+ b1.Property("VoteCount")
+ .HasColumnType("INTEGER");
+
+ b1.HasKey("Id");
+
+ b1.HasIndex("BookId");
+
+ b1.ToTable("BookRatings", (string)null);
+
+ b1.WithOwner()
+ .HasForeignKey("BookId");
+ });
+
+ b.OwnsMany("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary.IsbnEntity", "ISBNs", b1 =>
+ {
+ b1.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("TEXT");
+
+ b1.Property("BookId")
+ .HasColumnType("TEXT");
+
+ b1.Property("Format")
+ .IsRequired()
+ .HasMaxLength(6)
+ .HasColumnType("TEXT");
+
+ b1.Property("Value")
+ .IsRequired()
+ .HasMaxLength(13)
+ .HasColumnType("TEXT")
+ .HasColumnName("ISBN");
+
+ b1.HasKey("Id");
+
+ b1.HasIndex("BookId");
+
+ b1.ToTable("BookISBNs", (string)null);
+
+ b1.WithOwner()
+ .HasForeignKey("BookId");
+ });
+
+ b.Navigation("ISBNs");
+
+ b.Navigation("Ratings");
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.PermissionEntity", b =>
+ {
+ b.Navigation("RolePermissions");
+
+ b.Navigation("UserPermissions");
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.RoleEntity", b =>
+ {
+ b.Navigation("RolePermissions");
+
+ b.Navigation("UserRoles");
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.UsersManagement.UserEntity", b =>
+ {
+ b.Navigation("Libraries");
+
+ b.Navigation("UserPermissions");
+
+ b.Navigation("UserRole");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/src/Lumina.DataAccess/Common/Migrations/20250103134553_AddMediaLibraryCoverImageColumn.cs b/src/Lumina.DataAccess/Common/Migrations/20250103134553_AddMediaLibraryCoverImageColumn.cs
new file mode 100644
index 00000000..c03c5e6b
--- /dev/null
+++ b/src/Lumina.DataAccess/Common/Migrations/20250103134553_AddMediaLibraryCoverImageColumn.cs
@@ -0,0 +1,29 @@
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace Lumina.DataAccess.Common.Migrations;
+
+///
+public partial class AddMediaLibraryCoverImageColumn : Migration
+{
+ ///
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.AddColumn(
+ name: "CoverImage",
+ table: "Libraries",
+ type: "TEXT",
+ maxLength: 255,
+ nullable: true)
+ .Annotation("Relational:ColumnOrder", 3);
+ }
+
+ ///
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropColumn(
+ name: "CoverImage",
+ table: "Libraries");
+ }
+}
diff --git a/src/Lumina.DataAccess/Common/Migrations/LuminaDbContextModelSnapshot.cs b/src/Lumina.DataAccess/Common/Migrations/LuminaDbContextModelSnapshot.cs
index 322f9af8..d6abaff4 100644
--- a/src/Lumina.DataAccess/Common/Migrations/LuminaDbContextModelSnapshot.cs
+++ b/src/Lumina.DataAccess/Common/Migrations/LuminaDbContextModelSnapshot.cs
@@ -245,6 +245,11 @@ namespace Lumina.DataAccess.Common.Migrations
.HasColumnType("TEXT")
.HasColumnOrder(0);
+ b.Property("CoverImage")
+ .HasMaxLength(255)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(3);
+
b.Property("CreatedBy")
.HasColumnType("TEXT");
diff --git a/src/Lumina.Domain/Core/BoundedContexts/LibraryManagementBoundedContext/LibraryAggregate/Library.cs b/src/Lumina.Domain/Core/BoundedContexts/LibraryManagementBoundedContext/LibraryAggregate/Library.cs
index 626a0d5f..7446081b 100644
--- a/src/Lumina.Domain/Core/BoundedContexts/LibraryManagementBoundedContext/LibraryAggregate/Library.cs
+++ b/src/Lumina.Domain/Core/BoundedContexts/LibraryManagementBoundedContext/LibraryAggregate/Library.cs
@@ -35,6 +35,11 @@ public class Library : AggregateRoot
///
public string Title { get; private set; }
+ ///
+ /// Gets the path of the image file used as the cover for the library.
+ ///
+ public string? CoverImage { get; private set; }
+
///
/// Gets the list of file system paths that make up the media library.
///
@@ -48,17 +53,20 @@ public class Library : AggregateRoot
/// The title of the media library.
/// The type of the media library (e.g., Book, TvShow).
/// The list of file system paths that make up the media library.
+ /// The path of the image file used as the cover for the library.
private Library(
LibraryId id,
UserId userId,
string title,
LibraryType libraryType,
- List contentLocations) : base(id)
+ List contentLocations,
+ string? coverImage) : base(id)
{
UserId = userId;
Title = title;
LibraryType = libraryType;
_contentLocations = contentLocations;
+ CoverImage = coverImage;
}
///
@@ -68,6 +76,7 @@ public class Library : AggregateRoot
/// The title of the media library.
/// The type of the media library (e.g., Book, TvShow).
/// The list of file system paths that make up the media library.
+ /// The path of the image file used as the cover for the library.
///
/// An containing either a successfully created , or an error message.
///
@@ -75,7 +84,8 @@ public class Library : AggregateRoot
Guid userId,
string title,
LibraryType libraryType,
- IEnumerable contentLocations)
+ IEnumerable contentLocations,
+ string? coverImage)
{
List tempContentLocations = [];
// go through all the file system paths that make up the media library and create domain objects from them
@@ -91,7 +101,8 @@ public class Library : AggregateRoot
UserId.Create(userId),
title,
libraryType,
- tempContentLocations
+ tempContentLocations,
+ coverImage
);
}
@@ -103,6 +114,7 @@ public class Library : AggregateRoot
/// The title of the media library.
/// The type of the media library (e.g., Book, TvShow).
/// The list of file system paths that make up the media library.
+ /// The path of the image file used as the cover for the library.
///
/// An containing either a successfully created , or an error message.
///
@@ -111,7 +123,8 @@ public class Library : AggregateRoot
Guid userId,
string title,
LibraryType libraryType,
- IEnumerable contentLocations)
+ IEnumerable contentLocations,
+ string? coverImage)
{
List tempContentLocations = [];
// go through all the file system paths that make up the media library and create domain objects from them
@@ -127,7 +140,8 @@ public class Library : AggregateRoot
UserId.Create(userId),
title,
libraryType,
- tempContentLocations
+ tempContentLocations,
+ coverImage
);
}
}
diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/Library/Management/AddLibrary/AddLibraryEndpoint.cs b/src/Lumina.Presentation.Api/Core/Endpoints/Library/Management/AddLibrary/AddLibraryEndpoint.cs
index a46b1aba..7db5f519 100644
--- a/src/Lumina.Presentation.Api/Core/Endpoints/Library/Management/AddLibrary/AddLibraryEndpoint.cs
+++ b/src/Lumina.Presentation.Api/Core/Endpoints/Library/Management/AddLibrary/AddLibraryEndpoint.cs
@@ -8,8 +8,6 @@ using Lumina.Presentation.Api.Common.Routes.Library.Management;
using Lumina.Presentation.Api.Core.Endpoints.Common;
using Mediator;
using Microsoft.AspNetCore.Http;
-using System;
-using System.Security.Claims;
using System.Threading;
using System.Threading.Tasks;
#endregion
@@ -50,9 +48,7 @@ public class AddLibraryEndpoint : BaseEndpoint
/// Cancellation token that can be used to stop the execution.
public override async Task ExecuteAsync(AddLibraryRequest request, CancellationToken cancellationToken)
{
- // retrieve the currently authenticated user, and send it with the request // TODO: replace with current user service
- string? user = User.FindFirstValue(ClaimTypes.NameIdentifier);
- ErrorOr result = await _sender.Send(request.ToCommand(Guid.Parse(user!)), cancellationToken).ConfigureAwait(false);
+ ErrorOr result = await _sender.Send(request.ToCommand(), cancellationToken).ConfigureAwait(false);
return result.Match(success => TypedResults.Created($"{BaseURL}api/v1{ApiRoutes.Libraries.ADD_LIBRARY}/{result.Value.Id}", result.Value), Problem);
}
}
diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/Library/Management/AddLibrary/AddLibraryEndpointSummary.cs b/src/Lumina.Presentation.Api/Core/Endpoints/Library/Management/AddLibrary/AddLibraryEndpointSummary.cs
index 90d989c0..b5e40da2 100644
--- a/src/Lumina.Presentation.Api/Core/Endpoints/Library/Management/AddLibrary/AddLibraryEndpointSummary.cs
+++ b/src/Lumina.Presentation.Api/Core/Endpoints/Library/Management/AddLibrary/AddLibraryEndpointSummary.cs
@@ -30,18 +30,21 @@ public class AddLibraryEndpointSummary : Summary r.Title, "The title of the media library. Required.");
RequestParam(r => r.LibraryType, "The type of the media library. Required.");
- RequestParam(r => r.ContentLocations, ">The file system paths of the directories where the media library elements are located. Required.");
+ RequestParam(r => r.ContentLocations, "The file system paths of the directories where the media library elements are located. Required.");
+ RequestParam(r => r.CoverImage, "The path of the image file used as the cover for the library. Optional.");
ResponseParam(r => r.Id, "The unique identifier of the entity.");
ResponseParam(r => r.UserId, "The Id of the user owning the media library.");
ResponseParam(r => r.Title, "The title of the media library.");
ResponseParam(r => r.LibraryType, "The type of the media library.");
ResponseParam(r => r.ContentLocations, "The file system paths of the directories where the media library elements are located.");
+ ResponseParam(r => r.CoverImage, "The path of the image file used as the cover for the library.");
ResponseParam(r => r.CreatedOnUtc, "The date and time when the entity was created.");
ResponseParam(r => r.UpdatedOnUtc, "The date and time when the entity was last updated.");
@@ -53,6 +56,7 @@ public class AddLibraryEndpointSummary : Summary(r => r.Title, "The title of the media library.");
ResponseParam(r => r.LibraryType, "The type of the media library.");
ResponseParam(r => r.ContentLocations, "The file system paths of the directories where the media library elements are located.");
+ ResponseParam(r => r.CoverImage, "The path of the image file used as the cover for the library.");
ResponseParam(r => r.CreatedOnUtc, "The date and time when the entity was created.");
ResponseParam(r => r.UpdatedOnUtc, "The date and time when the entity was last updated.");
@@ -44,6 +45,7 @@ public class GetLibraryEndpointSummary : Summary
/// Cancellation token that can be used to stop the execution.
public override async Task ExecuteAsync(UpdateLibraryRequest request, CancellationToken cancellationToken)
{
- // retrieve the currently authenticated user, and send it with the request
- string? user = User.FindFirstValue(ClaimTypes.NameIdentifier);
- ErrorOr result = await _sender.Send(request.ToCommand(Guid.Parse(user!)), cancellationToken).ConfigureAwait(false);
+ ErrorOr result = await _sender.Send(request.ToCommand(), cancellationToken).ConfigureAwait(false);
return result.Match(success => TypedResults.Ok(success), Problem);
}
}
diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/Library/Management/UpdateLibrary/UpdateLibraryEndpointSummary.cs b/src/Lumina.Presentation.Api/Core/Endpoints/Library/Management/UpdateLibrary/UpdateLibraryEndpointSummary.cs
index 8e2a1762..4a2fa096 100644
--- a/src/Lumina.Presentation.Api/Core/Endpoints/Library/Management/UpdateLibrary/UpdateLibraryEndpointSummary.cs
+++ b/src/Lumina.Presentation.Api/Core/Endpoints/Library/Management/UpdateLibrary/UpdateLibraryEndpointSummary.cs
@@ -32,7 +32,8 @@ public class UpdateLibraryEndpointSummary : Summary r.Id, "The Id of the media library. Required.");
@@ -40,12 +41,14 @@ public class UpdateLibraryEndpointSummary : Summary r.Title, "The title of the media library. Required.");
RequestParam(r => r.LibraryType, "The type of the media library. Required.");
RequestParam(r => r.ContentLocations, ">The file system paths of the directories where the media library elements are located. Required.");
+ RequestParam(r => r.CoverImage, "The path of the image file used as the cover for the library. Optional.");
ResponseParam(r => r.Id, "The unique identifier of the entity.");
ResponseParam(r => r.UserId, "The Id of the user owning the media library.");
ResponseParam(r => r.Title, "The title of the media library.");
ResponseParam(r => r.LibraryType, "The type of the media library.");
ResponseParam(r => r.ContentLocations, "The file system paths of the directories where the media library elements are located.");
+ ResponseParam(r => r.CoverImage, "The path of the image file used as the cover for the library.");
ResponseParam(r => r.CreatedOnUtc, "The date and time when the entity was created.");
ResponseParam(r => r.UpdatedOnUtc, "The date and time when the entity was last updated.");
@@ -57,6 +60,7 @@ public class UpdateLibraryEndpointSummary : Summary
public string? LibraryType { get; set; }
+ ///
+ /// Gets or sets the path of the image file used as the cover for the library.
+ ///
+ public string? CoverImage { get; set; }
+
///
/// Gets or sets the collection of directories that contain the library files.
///
diff --git a/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Item.Designer.cs b/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Item.Designer.cs
index 11061b42..b9d621a7 100644
--- a/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Item.Designer.cs
+++ b/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Item.Designer.cs
@@ -78,6 +78,15 @@ namespace Lumina.Presentation.Web.Resources.Views.Library.Management {
}
}
+ ///
+ /// Looks up a localized string similar to Add image.
+ ///
+ public static string AddImage {
+ get {
+ return ResourceManager.GetString("AddImage", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Add New Library.
///
@@ -177,6 +186,24 @@ namespace Lumina.Presentation.Web.Resources.Views.Library.Management {
}
}
+ ///
+ /// Looks up a localized string similar to Cover Image.
+ ///
+ public static string CoverImage {
+ get {
+ return ResourceManager.GetString("CoverImage", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Select the image file that will be used as the cover for this library.
+ ///
+ public static string DescriptionCover {
+ get {
+ return ResourceManager.GetString("DescriptionCover", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Select the folders containing the media files of this library.
///
diff --git a/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Item.de-DE.resx b/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Item.de-DE.resx
index 8d2e1687..94373104 100644
--- a/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Item.de-DE.resx
+++ b/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Item.de-DE.resx
@@ -123,6 +123,9 @@
Verzeichnis hinzufügen
+
+ Bild hinzufügen
+
Neue Bibliothek Hinzufügen
@@ -156,6 +159,12 @@
Coverversion
+
+ Titelbild
+
+
+ Wählen Sie die Bilddatei aus, die als Cover für diese Bibliothek verwendet wird
+
Wählen Sie die Ordner mit den Mediendateien dieser Bibliothek aus
diff --git a/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Item.en-US.resx b/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Item.en-US.resx
index 25040e39..8c7d70e1 100644
--- a/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Item.en-US.resx
+++ b/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Item.en-US.resx
@@ -123,6 +123,9 @@
Add directory
+
+ Add image
+
Add New Library
@@ -156,6 +159,12 @@
Cover
+
+ Cover Image
+
+
+ Select the image file that will be used as the cover for this library
+
Select the folders containing the media files of this library
diff --git a/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Item.es-ES.resx b/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Item.es-ES.resx
index 6796118c..c35d9502 100644
--- a/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Item.es-ES.resx
+++ b/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Item.es-ES.resx
@@ -123,6 +123,9 @@
Agregar directorio
+
+ Añadir imagen
+
Agregar Nueva Biblioteca
@@ -156,6 +159,12 @@
Versión
+
+ Imagen De Portada
+
+
+ Seleccione el archivo de imagen que se usará como portada para esta biblioteca
+
Selecciona las carpetas que contienen los archivos multimedia de esta biblioteca
diff --git a/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Item.fr-FR.resx b/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Item.fr-FR.resx
index 4ddfcf86..bac6a7f9 100644
--- a/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Item.fr-FR.resx
+++ b/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Item.fr-FR.resx
@@ -123,6 +123,9 @@
Ajouter un répertoire
+
+ Ajouter une image
+
Ajouter Une Nouvelle Bibliothèque
@@ -156,6 +159,12 @@
Reprise
+
+ Image De Couverture
+
+
+ Sélectionnez le fichier image qui servira de couverture pour cette bibliothèque
+
Sélectionnez les dossiers contenant les fichiers multimédias de cette bibliothèque
diff --git a/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Item.it-IT.resx b/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Item.it-IT.resx
index 567d2362..90772f16 100644
--- a/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Item.it-IT.resx
+++ b/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Item.it-IT.resx
@@ -123,6 +123,9 @@
Aggiungi directory
+
+ Aggiungi immagine
+
Aggiungi Nuova Libreria
@@ -156,6 +159,12 @@
Reinterpretazione
+
+ Immagine Di Copertina
+
+
+ Seleziona il file immagine che sarà utilizzato come copertina per questa libreria
+
Seleziona le cartelle che contengono i file multimediali di questa biblioteca
diff --git a/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Item.ja-JP.resx b/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Item.ja-JP.resx
index 88405853..ce7ed5ce 100644
--- a/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Item.ja-JP.resx
+++ b/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Item.ja-JP.resx
@@ -123,6 +123,9 @@
ディレクトリを追加
+
+ 画像を追加
+
新しい ライブラリ 追加
@@ -156,6 +159,12 @@
カバー曲
+
+ カバー画像
+
+
+ このライブラリのカバーとして使用する画像ファイルを選択してください
+
このライブラリのメディアファイルを含むフォルダを選択してください
diff --git a/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Item.resx b/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Item.resx
index 25040e39..8c7d70e1 100644
--- a/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Item.resx
+++ b/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Item.resx
@@ -123,6 +123,9 @@
Add directory
+
+ Add image
+
Add New Library
@@ -156,6 +159,12 @@
Cover
+
+ Cover Image
+
+
+ Select the image file that will be used as the cover for this library
+
Select the folders containing the media files of this library
diff --git a/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Item.ro-RO.resx b/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Item.ro-RO.resx
index 313885cb..488819dc 100644
--- a/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Item.ro-RO.resx
+++ b/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Item.ro-RO.resx
@@ -123,6 +123,9 @@
Adaugă dosar
+
+ Adaugă imagine
+
Adaugă Bibliotecă Nouă
@@ -156,6 +159,12 @@
Preluare
+
+ Imagine Copertă
+
+
+ Selectează fișierul imagine care va fi folosit ca și copertă pentru această bibliotecă
+
Selectează dosarele care conțin fișierele media ale acestei biblioteci
diff --git a/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Item.ru-RU.resx b/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Item.ru-RU.resx
index 6fccbc97..e6764bab 100644
--- a/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Item.ru-RU.resx
+++ b/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Item.ru-RU.resx
@@ -123,6 +123,9 @@
Добавить директорию
+
+ Добавить изображение
+
Добавить Новую Библиотеку
@@ -156,6 +159,12 @@
Кавер
+
+ Обложка
+
+
+ Выберите файл изображения, который будет использоваться в качестве обложки для этой библиотеки
+
Выберите папки, содержащие медиафайлы этой библиотеки
diff --git a/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Item.zh-CN.resx b/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Item.zh-CN.resx
index 2e2ea69a..86a9b73b 100644
--- a/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Item.zh-CN.resx
+++ b/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Item.zh-CN.resx
@@ -123,6 +123,9 @@
添加目录
+
+ 添加图片
+
添加 新库
@@ -156,6 +159,12 @@
翻唱
+
+ 封面图片
+
+
+ 选择将用作此库封面的图片文件
+
选择包含该图书馆媒体文件的文件夹
diff --git a/src/Lumina.Presentation.Web/Views/Library/Management/Item.cshtml b/src/Lumina.Presentation.Web/Views/Library/Management/Item.cshtml
index 25f82330..e8eae3c0 100644
--- a/src/Lumina.Presentation.Web/Views/Library/Management/Item.cshtml
+++ b/src/Lumina.Presentation.Web/Views/Library/Management/Item.cshtml
@@ -103,6 +103,25 @@
@_localizer["DescriptionLibraryType"]
+
+
+
+ :
+
+
+
+
+
+ @if (Model.CoverImage is not null)
+ {
+
+ @Model.CoverImage
+
+
+ }
+
+ @_localizer["DescriptionCover"]
+
@@ -112,7 +131,7 @@
-
+
@for (int i = 0; i < Model.ContentLocations.Count; i++)
{
@@ -131,8 +150,8 @@
@_localizer["LibrarySaved"]
-
-
+
+
@@ -146,7 +165,9 @@
const btnAddNewLibrary = document.getElementById('btn-add-new-library');
const form = document.getElementById('add-media-library-form');
const imgAddMediaDirectory = document.getElementById('add-media-directory');
- const formTable = document.querySelector('.form-table');
+ const imgAddCover = document.getElementById('add-media-cover');
+ const mediaCoverFormTable = document.getElementById('add-media-cover-form-table');
+ const mediaDirectoriesFormTable = document.getElementById('add-media-directory-form-table');
// create new or update existing media library
async function handleAddMediaLibraryAsync() {
@@ -155,8 +176,13 @@
UserId: form.querySelector('[name="UserId"]').value || null,
Title: form.querySelector('[name="Title"]').value,
LibraryType: form.querySelector('#library-selected-item').getAttribute('data-value'),
- ContentLocations: Array.from(form.querySelectorAll('.form-table-row span'))
- .map(span => span.textContent)
+ ContentLocations: Array.from(mediaDirectoriesFormTable.querySelectorAll('.form-table-row span'))
+ .map(span => span.textContent),
+ CoverImage: (() => {
+ // get the first (and only) span in the mediaCoverFormTable, if it exists
+ const coverSpan = mediaCoverFormTable.querySelector('.form-table-row span');
+ return coverSpan ? coverSpan.textContent : null; // return null if no cover image is selected
+ })()
};
const data = await callApiPostAsync('@_urlService.GetAbsoluteUrl("SaveLibrary", "LibraryManagement")', formData);
if (data) {
@@ -167,19 +193,20 @@
}
}
- function addNewFileSystemPaths(selectedPaths) {
- // get the form table where the new paths will be added
- const formTable = document.querySelector('.form-table');
- // process the selected paths
+ function addMediaLibraryDirectories(selectedPaths) {
+ // process the selected paths (remove quotes and split by comma)
const paths = selectedPaths.slice(1, -1).split('","');
// add each path as a new row
paths.forEach(path => {
- // check if path already exists
- const existingPath = formTable.querySelector(`span[title="${path}"]`);
- if (!existingPath) {
- formTable.insertAdjacentHTML('beforeend', `
+ // normalize the path for comparison
+ const normalizedPath = path.replace(/\\\\/g, '\\');
+ // use querySelectorAll and compare explicitly, so that duplicates are not permitted
+ const existingPaths = Array.from(mediaDirectoriesFormTable.querySelectorAll('span[title]'));
+ const isDuplicate = existingPaths.some(span => span.getAttribute('title') === normalizedPath);
+ if (!isDuplicate) {
+ mediaDirectoriesFormTable.insertAdjacentHTML('beforeend', `
- ${path}
+ ${normalizedPath}
`);
@@ -187,6 +214,24 @@
});
}
+ function addMediaLibraryCoverImage(selectedPaths) {
+ // process the selected paths
+ const paths = selectedPaths.slice(1, -1).split('","');
+ // ensure only one row is allowed by first clearing all previous rows
+ mediaCoverFormTable.innerHTML = '';
+ // add the first valid path (if any) as a new row
+ if (paths.length > 0) {
+ const path = paths[0]; // only use the first path
+ mediaCoverFormTable.insertAdjacentHTML('beforeend', `
+
+ ${path}
+
+
+ `);
+ }
+ }
+
+
// on Enter key pressed
const handleEnterKey = async function(e) {
if (e.key === 'Enter') {
@@ -213,7 +258,12 @@
// on add media directory image click
const handleImgAddMediaDirectoryClick = async function() {
- await showFileSystemBrowserDialogAsync('C:\\Users\\', true, false, addNewFileSystemPaths); // TODO: take path and include hidden elements from settings
+ await showFileSystemBrowserDialogAsync('C:\\Users\\', true, false, addMediaLibraryDirectories); // TODO: take path and include hidden elements from settings
+ };
+
+ // on add cover image click
+ const handleImgAddCoverClick = async function() {
+ await showFileSystemBrowserDialogAsync('C:\\Users\\', true, true, addMediaLibraryCoverImage); // TODO: take path and include hidden elements from settings
};
// on remove row icon click
@@ -228,7 +278,9 @@
btnBackToLibraries.addEventListener('click', handleBtnBackToLibrariesClick);
btnAddNewLibrary.addEventListener('click', handleBtnAddNewLibraryClick);
imgAddMediaDirectory.addEventListener('click', handleImgAddMediaDirectoryClick);
- formTable.addEventListener('click', handleRowRemoval);
+ imgAddCover.addEventListener('click', handleImgAddCoverClick);
+ mediaCoverFormTable.addEventListener('click', handleRowRemoval);
+ mediaDirectoriesFormTable.addEventListener('click', handleRowRemoval);
// register cleanup for these listeners
cleanupFunctions.push(() => {
@@ -237,7 +289,9 @@
btnBackToLibraries.removeEventListener('click', handleBtnBackToLibrariesClick);
btnAddNewLibrary.removeEventListener('click', handleBtnAddNewLibraryClick);
imgAddMediaDirectory.removeEventListener('click', handleImgAddMediaDirectoryClick);
- formTable.removeEventListener('click', handleRowRemoval);
+ imgAddCover.removeEventListener('click', handleImgAddCoverClick);
+ mediaCoverFormTable.removeEventListener('click', handleRowRemoval);
+ mediaDirectoriesFormTable.removeEventListener('click', handleRowRemoval);
});
// store all cleanups for this view on window object using the scriptId
diff --git a/src/Lumina.Presentation.Web/wwwroot/images/ui/add-file.svg b/src/Lumina.Presentation.Web/wwwroot/images/ui/add-file.svg
new file mode 100644
index 00000000..a5c62320
--- /dev/null
+++ b/src/Lumina.Presentation.Web/wwwroot/images/ui/add-file.svg
@@ -0,0 +1,17 @@
+
+
diff --git a/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/MediaLibrary/Management/AddMediaLibraryRequestMappingTests.cs b/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/MediaLibrary/Management/AddMediaLibraryRequestMappingTests.cs
index 8b0ca998..e30b20fb 100644
--- a/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/MediaLibrary/Management/AddMediaLibraryRequestMappingTests.cs
+++ b/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/MediaLibrary/Management/AddMediaLibraryRequestMappingTests.cs
@@ -4,7 +4,6 @@ using Lumina.Application.Common.Mapping.MediaLibrary.Management;
using Lumina.Application.Core.MediaLibrary.Management.Commands.AddLibrary;
using Lumina.Contracts.Requests.MediaLibrary.Management;
using Lumina.Domain.Common.Enums.MediaLibrary;
-using System;
using System.Diagnostics.CodeAnalysis;
#endregion
@@ -20,22 +19,22 @@ public class AddMediaLibraryRequestMappingTests
public void ToCommand_WhenMappingValidRequest_ShouldMapCorrectly()
{
// Arrange
- Guid userId = Guid.NewGuid();
AddLibraryRequest request = new(
"My Library",
"Book",
- ["C:/Books", "D:/Media/Books"]
+ ["C:/Books", "D:/Media/Books"],
+ "D:/poster.jpg"
);
// Act
- AddLibraryCommand result = request.ToCommand(userId);
+ AddLibraryCommand result = request.ToCommand();
// Assert
result.Should().NotBeNull();
- result.UserId.Should().Be(userId);
result.Title.Should().Be(request.Title);
result.LibraryType.Should().Be(request.LibraryType);
result.ContentLocations.Should().BeEquivalentTo(request.ContentLocations);
+ result.CoverImage.Should().BeEquivalentTo(request.CoverImage);
}
[Theory]
@@ -46,22 +45,22 @@ public class AddMediaLibraryRequestMappingTests
public void ToCommand_WhenMappingDifferentLibraryTypes_ShouldMapCorrectly(LibraryType libraryType)
{
// Arrange
- Guid userId = Guid.NewGuid();
AddLibraryRequest request = new(
"My Library",
libraryType.ToString(),
- ["C:/Media"]
+ ["C:/Media"],
+ "D:/poster.jpg"
);
// Act
- AddLibraryCommand result = request.ToCommand(userId);
+ AddLibraryCommand result = request.ToCommand();
// Assert
result.Should().NotBeNull();
- result.UserId.Should().Be(userId);
result.Title.Should().Be(request.Title);
result.LibraryType.Should().Be(libraryType.ToString());
result.ContentLocations.Should().BeEquivalentTo(request.ContentLocations);
+ result.CoverImage.Should().BeEquivalentTo(request.CoverImage);
}
[Fact]
@@ -76,18 +75,43 @@ public class AddMediaLibraryRequestMappingTests
"F:/Reading Material"
];
- Guid userId = Guid.NewGuid();
AddLibraryRequest request = new(
"My Library",
"Book",
- contentLocations
+ contentLocations,
+ "D:/poster.jpg"
);
// Act
- AddLibraryCommand result = request.ToCommand(userId);
+ AddLibraryCommand result = request.ToCommand();
// Assert
result.Should().NotBeNull();
result.ContentLocations.Should().BeEquivalentTo(contentLocations);
}
+
+ [Fact]
+ public void ToCommand_WhenMappingWithNullCover_ShouldMapCorrectly()
+ {
+ // Arrange
+ string[] contentLocations =
+ [
+ "C:/Media/Books",
+ "D:/Books"
+ ];
+
+ AddLibraryRequest request = new(
+ "My Library",
+ "Book",
+ contentLocations,
+ null
+ );
+
+ // Act
+ AddLibraryCommand result = request.ToCommand();
+
+ // Assert
+ result.Should().NotBeNull();
+ result.CoverImage.Should().BeNull();
+ }
}
diff --git a/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/MediaLibrary/Management/LibraryEntityMappingTests.cs b/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/MediaLibrary/Management/LibraryEntityMappingTests.cs
index b93f0569..c12b0bf0 100644
--- a/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/MediaLibrary/Management/LibraryEntityMappingTests.cs
+++ b/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/MediaLibrary/Management/LibraryEntityMappingTests.cs
@@ -32,6 +32,7 @@ public class LibraryEntityMappingTests
new() { Path = "C:/Books" },
new() { Path = "D:/Media/Books" }
],
+ CoverImage = "D:/myPoster.jpg",
CreatedOnUtc = DateTime.UtcNow,
CreatedBy = Guid.NewGuid(),
UpdatedOnUtc = null,
@@ -48,6 +49,7 @@ public class LibraryEntityMappingTests
result.Title.Should().Be(entity.Title);
result.LibraryType.Should().Be(entity.LibraryType);
result.ContentLocations.Should().BeEquivalentTo(entity.ContentLocations.Select(l => l.Path));
+ result.CoverImage.Should().Be(entity.CoverImage);
result.CreatedOnUtc.Should().Be(entity.CreatedOnUtc);
result.UpdatedOnUtc.Should().Be(entity.UpdatedOnUtc);
}
@@ -67,6 +69,7 @@ public class LibraryEntityMappingTests
Title = "My Library",
LibraryType = libraryType,
ContentLocations = [new() { Path = "C:/Media" }],
+ CoverImage = "D:/myPoster.jpg",
CreatedOnUtc = DateTime.UtcNow,
CreatedBy = Guid.NewGuid(),
UpdatedOnUtc = null,
@@ -98,6 +101,7 @@ public class LibraryEntityMappingTests
new() { Path = "E:/Digital Library/Books" },
new() { Path = "F:/Reading Material" }
],
+ CoverImage = "D:/myPoster.jpg",
CreatedOnUtc = DateTime.UtcNow,
CreatedBy = Guid.NewGuid(),
UpdatedOnUtc = null,
@@ -124,6 +128,7 @@ public class LibraryEntityMappingTests
Title = "My Library",
LibraryType = LibraryType.Book,
ContentLocations = [new() { Path = "C:/Books" }],
+ CoverImage = "D:/myPoster.jpg",
CreatedOnUtc = DateTime.UtcNow,
CreatedBy = Guid.NewGuid(),
UpdatedOnUtc = updated,
@@ -137,4 +142,31 @@ public class LibraryEntityMappingTests
result.Should().NotBeNull();
result.UpdatedOnUtc.Should().Be(updated);
}
+
+ [Fact]
+ public void ToResponse_WhenMappingWithNullCoverImage_ShouldMapCorrectly()
+ {
+ // Arrange
+ DateTime updated = DateTime.UtcNow.AddDays(-1);
+ LibraryEntity entity = new()
+ {
+ Id = Guid.NewGuid(),
+ UserId = Guid.NewGuid(),
+ Title = "My Library",
+ LibraryType = LibraryType.Book,
+ ContentLocations = [new() { Path = "C:/Books" }],
+ CoverImage = null,
+ CreatedOnUtc = DateTime.UtcNow,
+ CreatedBy = Guid.NewGuid(),
+ UpdatedOnUtc = updated,
+ UpdatedBy = Guid.NewGuid()
+ };
+
+ // Act
+ LibraryResponse result = entity.ToResponse();
+
+ // Assert
+ result.Should().NotBeNull();
+ result.CoverImage.Should().BeNull();
+ }
}
diff --git a/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/MediaLibrary/Management/LibraryMappingTests.cs b/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/MediaLibrary/Management/LibraryMappingTests.cs
index 75623db2..d024f92f 100644
--- a/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/MediaLibrary/Management/LibraryMappingTests.cs
+++ b/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/MediaLibrary/Management/LibraryMappingTests.cs
@@ -29,7 +29,8 @@ public class LibraryMappingTests
Guid.NewGuid(),
"Test Library",
LibraryType.Book,
- ["C:/Books", "D:/Media/Books"]
+ ["C:/Books", "D:/Media/Books"],
+ "D:/myPoster.jpg"
);
Library library = libraryResult.Value;
@@ -44,6 +45,7 @@ public class LibraryMappingTests
result.LibraryType.Should().Be(library.LibraryType);
result.ContentLocations.Select(l => l.Path)
.Should().BeEquivalentTo(library.ContentLocations.Select(l => l.Path));
+ result.CoverImage.Should().BeEquivalentTo(library.CoverImage);
result.CreatedOnUtc.Should().Be(library.CreatedOnUtc);
result.UpdatedOnUtc.Should().Be(library.UpdatedOnUtc.HasValue ? library.UpdatedOnUtc : null);
}
@@ -56,7 +58,8 @@ public class LibraryMappingTests
Guid.NewGuid(),
"Empty Library",
LibraryType.Book,
- []
+ [],
+ "D:/myPoster.jpg"
);
Library library = libraryResult.Value;
@@ -66,6 +69,7 @@ public class LibraryMappingTests
// Assert
result.Should().NotBeNull();
result.ContentLocations.Should().BeEmpty();
+ result.CoverImage.Should().BeEquivalentTo(library.CoverImage);
}
[Theory]
@@ -80,7 +84,8 @@ public class LibraryMappingTests
Guid.NewGuid(),
"Test Library",
libraryType,
- ["C:/Media"]
+ ["C:/Media"],
+ "D:/myPoster.jpg"
);
Library library = libraryResult.Value;
@@ -90,6 +95,7 @@ public class LibraryMappingTests
// Assert
result.Should().NotBeNull();
result.LibraryType.Should().Be(libraryType);
+ result.CoverImage.Should().BeEquivalentTo(library.CoverImage);
}
[Fact]
@@ -108,7 +114,8 @@ public class LibraryMappingTests
Guid.NewGuid(),
"Test Library",
LibraryType.Book,
- contentLocations
+ contentLocations,
+ "D:/myPoster.jpg"
);
Library library = libraryResult.Value;
@@ -119,5 +126,35 @@ public class LibraryMappingTests
result.Should().NotBeNull();
result.ContentLocations.Select(l => l.Path)
.Should().BeEquivalentTo(library.ContentLocations.Select(l => l.Path));
+ result.CoverImage.Should().BeEquivalentTo(library.CoverImage);
+ }
+
+ [Fact]
+ public void ToRepositoryEntity_WhenMappingNullCoverimage_ShouldMapCorrectly()
+ {
+ // Arrange
+ List contentLocations =
+ [
+ "C:/Media/Books",
+ "D:/Books"
+ ];
+
+ ErrorOr libraryResult = Library.Create(
+ Guid.NewGuid(),
+ "Test Library",
+ LibraryType.Book,
+ contentLocations,
+ null
+ );
+ Library library = libraryResult.Value;
+
+ // Act
+ LibraryEntity result = library.ToRepositoryEntity();
+
+ // Assert
+ result.Should().NotBeNull();
+ result.ContentLocations.Select(l => l.Path)
+ .Should().BeEquivalentTo(library.ContentLocations.Select(l => l.Path));
+ result.CoverImage.Should().BeNull();
}
}
diff --git a/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/Management/Fixtures/DomainLibraryFixture.cs b/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/Management/Fixtures/DomainLibraryFixture.cs
index eb981649..1a019125 100644
--- a/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/Management/Fixtures/DomainLibraryFixture.cs
+++ b/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/Management/Fixtures/DomainLibraryFixture.cs
@@ -1,7 +1,6 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using ErrorOr;
-using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary;
using Lumina.Domain.Common.Enums.MediaLibrary;
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate;
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
@@ -48,7 +47,8 @@ public class DomainLibraryFixture
Guid.NewGuid(),
_faker.Random.String2(_faker.Random.Number(1, 50)),
_faker.PickRandom(),
- validPaths.Take(_random.Next(1, validPaths.Count))
+ validPaths.Take(_random.Next(1, validPaths.Count)),
+ _faker.System.FilePath()
);
return library.Value;
@@ -59,21 +59,24 @@ public class DomainLibraryFixture
Guid? userId = null,
string? title = null,
LibraryType? libraryType = null,
- IEnumerable? contentLocations = null)
+ IEnumerable? contentLocations = null,
+ string? coverImage = null)
{
ErrorOr library = id is null ?
Library.Create(
userId ?? Guid.NewGuid(),
title ?? _faker.Random.String2(_faker.Random.Number(1, 50)),
libraryType ?? LibraryType.Book,
- contentLocations ?? ["C:/Media"]
+ contentLocations ?? ["C:/Media"],
+ coverImage
) :
Library.Create(
LibraryId.Create(id.Value),
userId ?? Guid.NewGuid(),
title ?? _faker.Random.String2(_faker.Random.Number(1, 50)),
libraryType ?? LibraryType.Book,
- contentLocations ?? ["C:/Media"]
+ contentLocations ?? ["C:/Media"],
+ coverImage
);
return library.Value;