mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-01 18:57:24 +00:00
Adds media library cover image
This commit is contained in:
1 parent
89debaeaad
commit
666a739b1d
43 files changed
+1170
-94
No files matched your search
@@ -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)
|
||||
|
||||
+5
@@ -30,6 +30,11 @@ public class LibraryEntity : IStorageEntity, IAuditableEntity
|
||||
/// </summary>
|
||||
public required string Title { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the path of the image file used as the cover for the library.
|
||||
/// </summary>
|
||||
public string? CoverImage { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the type of the media library.
|
||||
/// </summary>
|
||||
|
||||
+3
-4
@@ -17,15 +17,14 @@ public static class AddMediaLibraryRequestMapping
|
||||
/// Converts <paramref name="request"/> to <see cref="AddLibraryCommand"/>.
|
||||
/// </summary>
|
||||
/// <param name="request">The request to be converted.</param>
|
||||
/// <param name="userId">The Id of the user owning the media library.</param>
|
||||
/// <returns>The converted command.</returns>
|
||||
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
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
);
|
||||
|
||||
@@ -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,
|
||||
|
||||
+3
-4
@@ -15,17 +15,16 @@ public static class UpdateLibraryRequestMapping
|
||||
/// Converts <paramref name="request"/> to <see cref="UpdateLibraryCommand"/>.
|
||||
/// </summary>
|
||||
/// <param name="request">The request to be converted.</param>
|
||||
/// <param name="userId">The Id of the user making the request to update the media library.</param>
|
||||
/// <returns>The converted command.</returns>
|
||||
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
|
||||
);
|
||||
}
|
||||
}
|
||||
+4
-4
@@ -11,14 +11,14 @@ 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="Title">The title of 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>
|
||||
/// <param name="CoverImage">The path of the image file used as the cover for the library.</param>
|
||||
[DebuggerDisplay("Title: {Title}")]
|
||||
public record AddLibraryCommand(
|
||||
Guid UserId,
|
||||
string? Title,
|
||||
string? LibraryType,
|
||||
string[]? ContentLocations
|
||||
string[]? ContentLocations,
|
||||
string? CoverImage
|
||||
) : IRequest<ErrorOr<LibraryResponse>>;
|
||||
+8
-3
@@ -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<AddLibraryCommand, ErrorOr<LibraryResponse>>
|
||||
{
|
||||
private readonly IUnitOfWork _unitOfWork;
|
||||
private readonly ICurrentUserService _currentUserService;
|
||||
|
||||
/// <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)
|
||||
/// <param name="currentUserService">Injected service to retrieve the current user information.</param>
|
||||
public AddLibraryCommandHandler(IUnitOfWork unitOfWork, ICurrentUserService currentUserService)
|
||||
{
|
||||
_unitOfWork = unitOfWork;
|
||||
_currentUserService = currentUserService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -44,10 +48,11 @@ public class AddLibraryCommandHandler : IRequestHandler<AddLibraryCommand, Error
|
||||
{
|
||||
// create a domain library object
|
||||
ErrorOr<Library> createLibraryResult = Library.Create(
|
||||
request.UserId,
|
||||
_currentUserService.UserId!.Value,
|
||||
request.Title!,
|
||||
Enum.Parse<LibraryType>(request.LibraryType!),
|
||||
request.ContentLocations!
|
||||
request.ContentLocations!,
|
||||
request.CoverImage
|
||||
);
|
||||
|
||||
if (createLibraryResult.IsError)
|
||||
|
||||
-4
@@ -17,10 +17,6 @@ public class AddLibraryCommandValidator : AbstractValidator<AddLibraryCommand>
|
||||
/// </summary>
|
||||
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<LibraryType>(x, out _))
|
||||
|
||||
+4
-5
@@ -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
|
||||
/// </summary>
|
||||
/// <param name="Id">The Id of the media library.</param>
|
||||
/// <param name="OwnerId">The Id of the user owning the media library.</param>
|
||||
/// <param name="CurrentUserId">The Id of the user making the request to update the media library.</param>
|
||||
/// <param name="Title">The title of 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>
|
||||
/// <param name="CoverImage">The path of the image file used as the cover for the library.</param>
|
||||
[DebuggerDisplay("Title: {Title}")]
|
||||
public record UpdateLibraryCommand(
|
||||
Guid Id,
|
||||
Guid OwnerId,
|
||||
Guid CurrentUserId,
|
||||
string? Title,
|
||||
string? LibraryType,
|
||||
string[]? ContentLocations
|
||||
string[]? ContentLocations,
|
||||
string? CoverImage
|
||||
) : IRequest<ErrorOr<LibraryResponse>>;
|
||||
+12
-3
@@ -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<UpdateLibraryCommand, ErrorOr<LibraryResponse>>
|
||||
{
|
||||
private readonly IUnitOfWork _unitOfWork;
|
||||
private readonly ICurrentUserService _currentUserService;
|
||||
private readonly IAuthorizationService _authorizationService;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="UpdateLibraryCommandHandler"/> class.
|
||||
/// </summary>
|
||||
/// <param name="authorizationService">Injected service for authorization related functionality.</param>
|
||||
/// <param name="currentUserService">Injected service to retrieve the current user information.</param>
|
||||
/// <param name="unitOfWork">Injected unit of work for interacting with the data access layer repositories.</param>
|
||||
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<UpdateLibraryCommand,
|
||||
else if (getLibraryResult.Value is null)
|
||||
return DomainErrors.Library.LibraryNotFound;
|
||||
// if the user that made the request is not an Admin or is not the owner of the library, they do not have the right to update it
|
||||
if (getLibraryResult.Value.UserId != request.CurrentUserId) // TODO: after implementing the Admin role, add that permission check here too
|
||||
if (getLibraryResult.Value.UserId != _currentUserService.UserId || !await _authorizationService.IsInRoleAsync(_currentUserService.UserId!.Value, "Admin", cancellationToken))
|
||||
return ApplicationErrors.Authorization.NotAuthorized;
|
||||
|
||||
// create a domain library object
|
||||
@@ -61,7 +69,8 @@ public class UpdateLibraryCommandHandler : IRequestHandler<UpdateLibraryCommand,
|
||||
request.OwnerId,
|
||||
request.Title!,
|
||||
Enum.Parse<LibraryType>(request.LibraryType!),
|
||||
request.ContentLocations!
|
||||
request.ContentLocations!,
|
||||
request.CoverImage
|
||||
);
|
||||
if (createLibraryResult.IsError)
|
||||
return createLibraryResult.Errors;
|
||||
|
||||
-4
@@ -21,10 +21,6 @@ public class UpdateLibraryCommandValidator : AbstractValidator<UpdateLibraryComm
|
||||
.NotEmpty().WithMessage(Errors.Library.LibraryIdCannotBeEmpty.Description)
|
||||
.Must(id => 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);
|
||||
|
||||
@@ -10,9 +10,11 @@ namespace Lumina.Contracts.Requests.MediaLibrary.Management;
|
||||
/// <param name="Title">The title of the media library. Required.</param>
|
||||
/// <param name="LibraryType">The type of the media library. Required.</param>
|
||||
/// <param name="ContentLocations">The file system paths of the directories where the media library elements are located. Required.</param>
|
||||
/// <param name="CoverImage">The path of the image file used as the cover for the library. Optional.</param>
|
||||
[DebuggerDisplay("Title: {Title}")]
|
||||
public record AddLibraryRequest(
|
||||
string? Title,
|
||||
string? LibraryType,
|
||||
string[]? ContentLocations
|
||||
string[]? ContentLocations,
|
||||
string? CoverImage
|
||||
);
|
||||
@@ -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;
|
||||
/// <param name="Title">The title of the media library. Required.</param>
|
||||
/// <param name="LibraryType">The type of the media library. Required.</param>
|
||||
/// <param name="ContentLocations">The file system paths of the directories where the media library elements are located. Required.</param>
|
||||
/// <param name="CoverImage">The path of the image file used as the cover for the library. Optional.</param>
|
||||
[DebuggerDisplay("Title: {Title}")]
|
||||
public record class UpdateLibraryRequest(
|
||||
Guid Id,
|
||||
Guid UserId,
|
||||
string? Title,
|
||||
string? LibraryType,
|
||||
string[]? ContentLocations
|
||||
string[]? ContentLocations,
|
||||
string? CoverImage
|
||||
);
|
||||
@@ -15,6 +15,7 @@ namespace Lumina.Contracts.Responses.MediaLibrary.Management;
|
||||
/// <param name="Title">The title of 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="CoverImage">The path of the image file used as the cover for the library.</param>
|
||||
/// <param name="CreatedOnUtc">The date and time when the library was created.</param>
|
||||
/// <param name="UpdatedOnUtc">The optional date and time when the library was updated.</param>
|
||||
[DebuggerDisplay("Title: {Title}")]
|
||||
@@ -24,6 +25,7 @@ public record LibraryResponse(
|
||||
string Title,
|
||||
LibraryType LibraryType,
|
||||
List<string> ContentLocations,
|
||||
string? CoverImage,
|
||||
DateTime CreatedOnUtc,
|
||||
DateTime? UpdatedOnUtc
|
||||
);
|
||||
@@ -28,12 +28,17 @@ public class LibraryConfiguration : IEntityTypeConfiguration<LibraryEntity>
|
||||
.IsRequired()
|
||||
.HasMaxLength(255)
|
||||
.HasColumnOrder(1);
|
||||
|
||||
|
||||
builder.Property(library => library.LibraryType)
|
||||
.IsRequired()
|
||||
.HasConversion<string>()
|
||||
.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)
|
||||
|
||||
Generated
+714
@@ -0,0 +1,714 @@
|
||||
// <auto-generated />
|
||||
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
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder.HasAnnotation("ProductVersion", "9.0.0");
|
||||
|
||||
modelBuilder.Entity("BookGenres", b =>
|
||||
{
|
||||
b.Property<Guid>("BookId")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("GenreId")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("BookId", "GenreId");
|
||||
|
||||
b.HasIndex("GenreId");
|
||||
|
||||
b.ToTable("BookGenres", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BookTags", b =>
|
||||
{
|
||||
b.Property<Guid>("BookId")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("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<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(0);
|
||||
|
||||
b.Property<Guid>("CreatedBy")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(4);
|
||||
|
||||
b.Property<DateTime>("CreatedOnUtc")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(3);
|
||||
|
||||
b.Property<string>("PermissionName")
|
||||
.IsRequired()
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(1);
|
||||
|
||||
b.Property<Guid?>("UpdatedBy")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(6);
|
||||
|
||||
b.Property<DateTime?>("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<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(0);
|
||||
|
||||
b.Property<Guid>("CreatedBy")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(4);
|
||||
|
||||
b.Property<DateTime>("CreatedOnUtc")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(3);
|
||||
|
||||
b.Property<string>("RoleName")
|
||||
.IsRequired()
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(1);
|
||||
|
||||
b.Property<Guid?>("UpdatedBy")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(6);
|
||||
|
||||
b.Property<DateTime?>("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<Guid>("RoleId")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<Guid>("PermissionId")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<Guid>("CreatedBy")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(2);
|
||||
|
||||
b.Property<DateTime>("CreatedOnUtc")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(1);
|
||||
|
||||
b.Property<Guid?>("UpdatedBy")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(4);
|
||||
|
||||
b.Property<DateTime?>("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<Guid>("UserId")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<Guid>("PermissionId")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<Guid>("CreatedBy")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(2);
|
||||
|
||||
b.Property<DateTime>("CreatedOnUtc")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(1);
|
||||
|
||||
b.Property<Guid?>("UpdatedBy")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(4);
|
||||
|
||||
b.Property<DateTime?>("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<Guid>("UserId")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<Guid>("CreatedBy")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(2);
|
||||
|
||||
b.Property<DateTime>("CreatedOnUtc")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(1);
|
||||
|
||||
b.Property<Guid>("RoleId")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<Guid?>("UpdatedBy")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(4);
|
||||
|
||||
b.Property<DateTime?>("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<string>("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<string>("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<Guid>("Id")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(0);
|
||||
|
||||
b.Property<string>("CoverImage")
|
||||
.HasMaxLength(255)
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(3);
|
||||
|
||||
b.Property<Guid>("CreatedBy")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<DateTime>("CreatedOnUtc")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("LibraryType")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(2);
|
||||
|
||||
b.Property<string>("Title")
|
||||
.IsRequired()
|
||||
.HasMaxLength(255)
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(1);
|
||||
|
||||
b.Property<Guid?>("UpdatedBy")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<DateTime?>("UpdatedOnUtc")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<Guid>("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<Guid>("Id")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(0);
|
||||
|
||||
b.Property<string>("ASIN")
|
||||
.HasMaxLength(10)
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(21);
|
||||
|
||||
b.Property<string>("AppleBooksId")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(29);
|
||||
|
||||
b.Property<string>("BarnesAndNobleId")
|
||||
.HasMaxLength(10)
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(28);
|
||||
|
||||
b.Property<Guid>("CreatedBy")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<DateTime>("CreatedOnUtc")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(30);
|
||||
|
||||
b.Property<string>("Description")
|
||||
.HasMaxLength(2000)
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(3);
|
||||
|
||||
b.Property<string>("Edition")
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(19);
|
||||
|
||||
b.Property<string>("Format")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(18);
|
||||
|
||||
b.Property<string>("GoodreadsId")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(22);
|
||||
|
||||
b.Property<string>("GoogleBooksId")
|
||||
.HasMaxLength(12)
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(27);
|
||||
|
||||
b.Property<string>("LCCN")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(23);
|
||||
|
||||
b.Property<string>("LanguageCode")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(10);
|
||||
|
||||
b.Property<string>("LanguageName")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(11);
|
||||
|
||||
b.Property<string>("LanguageNativeName")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(12);
|
||||
|
||||
b.Property<string>("LibraryThingId")
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(26);
|
||||
|
||||
b.Property<string>("OCLCNumber")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(24);
|
||||
|
||||
b.Property<string>("OpenLibraryId")
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(25);
|
||||
|
||||
b.Property<string>("OriginalLanguageCode")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(13);
|
||||
|
||||
b.Property<string>("OriginalLanguageName")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(14);
|
||||
|
||||
b.Property<string>("OriginalLanguageNativeName")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(15);
|
||||
|
||||
b.Property<DateOnly?>("OriginalReleaseDate")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(4);
|
||||
|
||||
b.Property<int?>("OriginalReleaseYear")
|
||||
.HasColumnType("INTEGER")
|
||||
.HasColumnOrder(5);
|
||||
|
||||
b.Property<string>("OriginalTitle")
|
||||
.HasMaxLength(255)
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(2);
|
||||
|
||||
b.Property<int?>("PageCount")
|
||||
.HasColumnType("INTEGER")
|
||||
.HasColumnOrder(17);
|
||||
|
||||
b.Property<string>("Publisher")
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(16);
|
||||
|
||||
b.Property<DateOnly?>("ReReleaseDate")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(6);
|
||||
|
||||
b.Property<int?>("ReReleaseYear")
|
||||
.HasColumnType("INTEGER")
|
||||
.HasColumnOrder(7);
|
||||
|
||||
b.Property<string>("ReleaseCountry")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(8);
|
||||
|
||||
b.Property<string>("ReleaseVersion")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(9);
|
||||
|
||||
b.Property<string>("Title")
|
||||
.IsRequired()
|
||||
.HasMaxLength(255)
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(1);
|
||||
|
||||
b.Property<Guid?>("UpdatedBy")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<DateTime?>("UpdatedOnUtc")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(31);
|
||||
|
||||
b.Property<int?>("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<Guid>("Id")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(0);
|
||||
|
||||
b.Property<Guid>("CreatedBy")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(7);
|
||||
|
||||
b.Property<DateTime>("CreatedOnUtc")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(6);
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(2);
|
||||
|
||||
b.Property<string>("TempPassword")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(3);
|
||||
|
||||
b.Property<DateTime?>("TempPasswordCreated")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(5);
|
||||
|
||||
b.Property<string>("TotpSecret")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(4);
|
||||
|
||||
b.Property<Guid?>("UpdatedBy")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(9);
|
||||
|
||||
b.Property<DateTime?>("UpdatedOnUtc")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(8);
|
||||
|
||||
b.Property<string>("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<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b1.Property<Guid>("LibraryId")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b1.Property<string>("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<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b1.Property<Guid>("BookId")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b1.Property<decimal>("MaxValue")
|
||||
.HasColumnType("decimal(3,2)");
|
||||
|
||||
b1.Property<string>("Source")
|
||||
.IsRequired()
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b1.Property<decimal>("Value")
|
||||
.HasColumnType("decimal(3,2)");
|
||||
|
||||
b1.Property<int?>("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<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b1.Property<Guid>("BookId")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b1.Property<string>("Format")
|
||||
.IsRequired()
|
||||
.HasMaxLength(6)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b1.Property<string>("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
|
||||
}
|
||||
}
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Lumina.DataAccess.Common.Migrations;
|
||||
|
||||
/// <inheritdoc />
|
||||
public partial class AddMediaLibraryCoverImageColumn : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "CoverImage",
|
||||
table: "Libraries",
|
||||
type: "TEXT",
|
||||
maxLength: 255,
|
||||
nullable: true)
|
||||
.Annotation("Relational:ColumnOrder", 3);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "CoverImage",
|
||||
table: "Libraries");
|
||||
}
|
||||
}
|
||||
@@ -245,6 +245,11 @@ namespace Lumina.DataAccess.Common.Migrations
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(0);
|
||||
|
||||
b.Property<string>("CoverImage")
|
||||
.HasMaxLength(255)
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnOrder(3);
|
||||
|
||||
b.Property<Guid>("CreatedBy")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
|
||||
+19
-5
@@ -35,6 +35,11 @@ public class Library : AggregateRoot<LibraryId>
|
||||
/// </summary>
|
||||
public string Title { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the path of the image file used as the cover for the library.
|
||||
/// </summary>
|
||||
public string? CoverImage { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the list of file system paths that make up the media library.
|
||||
/// </summary>
|
||||
@@ -48,17 +53,20 @@ public class Library : AggregateRoot<LibraryId>
|
||||
/// <param name="title">The title of the media library.</param>
|
||||
/// <param name="libraryType">The type of the media library (e.g., Book, TvShow).</param>
|
||||
/// <param name="contentLocations">The list of file system paths that make up the media library.</param>
|
||||
/// <param name="coverImage">The path of the image file used as the cover for the library.</param>
|
||||
private Library(
|
||||
LibraryId id,
|
||||
UserId userId,
|
||||
string title,
|
||||
LibraryType libraryType,
|
||||
List<FileSystemPathId> contentLocations) : base(id)
|
||||
List<FileSystemPathId> contentLocations,
|
||||
string? coverImage) : base(id)
|
||||
{
|
||||
UserId = userId;
|
||||
Title = title;
|
||||
LibraryType = libraryType;
|
||||
_contentLocations = contentLocations;
|
||||
CoverImage = coverImage;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -68,6 +76,7 @@ public class Library : AggregateRoot<LibraryId>
|
||||
/// <param name="title">The title of the media library.</param>
|
||||
/// <param name="libraryType">The type of the media library (e.g., Book, TvShow).</param>
|
||||
/// <param name="contentLocations">The list of file system paths that make up the media library.</param>
|
||||
/// <param name="coverImage">The path of the image file used as the cover for the library.</param>
|
||||
/// <returns>
|
||||
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="Library"/>, or an error message.
|
||||
/// </returns>
|
||||
@@ -75,7 +84,8 @@ public class Library : AggregateRoot<LibraryId>
|
||||
Guid userId,
|
||||
string title,
|
||||
LibraryType libraryType,
|
||||
IEnumerable<string> contentLocations)
|
||||
IEnumerable<string> contentLocations,
|
||||
string? coverImage)
|
||||
{
|
||||
List<FileSystemPathId> 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<LibraryId>
|
||||
UserId.Create(userId),
|
||||
title,
|
||||
libraryType,
|
||||
tempContentLocations
|
||||
tempContentLocations,
|
||||
coverImage
|
||||
);
|
||||
}
|
||||
|
||||
@@ -103,6 +114,7 @@ public class Library : AggregateRoot<LibraryId>
|
||||
/// <param name="title">The title of the media library.</param>
|
||||
/// <param name="libraryType">The type of the media library (e.g., Book, TvShow).</param>
|
||||
/// <param name="contentLocations">The list of file system paths that make up the media library.</param>
|
||||
/// <param name="coverImage">The path of the image file used as the cover for the library.</param>
|
||||
/// <returns>
|
||||
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="Library"/>, or an error message.
|
||||
/// </returns>
|
||||
@@ -111,7 +123,8 @@ public class Library : AggregateRoot<LibraryId>
|
||||
Guid userId,
|
||||
string title,
|
||||
LibraryType libraryType,
|
||||
IEnumerable<string> contentLocations)
|
||||
IEnumerable<string> contentLocations,
|
||||
string? coverImage)
|
||||
{
|
||||
List<FileSystemPathId> 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<LibraryId>
|
||||
UserId.Create(userId),
|
||||
title,
|
||||
libraryType,
|
||||
tempContentLocations
|
||||
tempContentLocations,
|
||||
coverImage
|
||||
);
|
||||
}
|
||||
}
|
||||
+1
-5
@@ -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<AddLibraryRequest, IResult>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
public override async Task<IResult> 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<LibraryResponse> result = await _sender.Send(request.ToCommand(Guid.Parse(user!)), cancellationToken).ConfigureAwait(false);
|
||||
ErrorOr<LibraryResponse> 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);
|
||||
}
|
||||
}
|
||||
+8
-3
@@ -30,18 +30,21 @@ public class AddLibraryEndpointSummary : Summary<AddLibraryEndpoint, AddLibraryR
|
||||
ContentLocations: [
|
||||
"/media/tv shows/drama/",
|
||||
"/media/tv shows/SCI-FI/",
|
||||
]
|
||||
],
|
||||
CoverImage: "/media/posters/myPoster.jpg"
|
||||
);
|
||||
|
||||
RequestParam(r => 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<LibraryResponse>(r => r.Id, "The unique identifier of the entity.");
|
||||
ResponseParam<LibraryResponse>(r => r.UserId, "The Id of the user owning the media library.");
|
||||
ResponseParam<LibraryResponse>(r => r.Title, "The title of the media library.");
|
||||
ResponseParam<LibraryResponse>(r => r.LibraryType, "The type of the media library.");
|
||||
ResponseParam<LibraryResponse>(r => r.ContentLocations, "The file system paths of the directories where the media library elements are located.");
|
||||
ResponseParam<LibraryResponse>(r => r.CoverImage, "The path of the image file used as the cover for the library.");
|
||||
ResponseParam<LibraryResponse>(r => r.CreatedOnUtc, "The date and time when the entity was created.");
|
||||
ResponseParam<LibraryResponse>(r => r.UpdatedOnUtc, "The date and time when the entity was last updated.");
|
||||
|
||||
@@ -53,6 +56,7 @@ public class AddLibraryEndpointSummary : Summary<AddLibraryEndpoint, AddLibraryR
|
||||
Title: "TV Shows",
|
||||
LibraryType: LibraryType.TvShow,
|
||||
ContentLocations: ["/media/tv shows/drama/", "/media/tv shows/SCI-FI/"],
|
||||
CoverImage: "/media/myPoster.jpg",
|
||||
CreatedOnUtc: DateTime.UtcNow,
|
||||
UpdatedOnUtc: default
|
||||
));
|
||||
@@ -108,7 +112,8 @@ public class AddLibraryEndpointSummary : Summary<AddLibraryEndpoint, AddLibraryR
|
||||
"PathsListCannotBeEmpty",
|
||||
"PathCannotBeEmpty",
|
||||
"TitleCannotBeEmpty",
|
||||
"TitleMustBeMaximum255CharactersLong"
|
||||
"TitleMustBeMaximum255CharactersLong",
|
||||
"CoverFileMustBeAnImage"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
+2
-1
@@ -35,6 +35,7 @@ public class GetLibraryEndpointSummary : Summary<GetLibraryEndpoint, GetLibraryR
|
||||
ResponseParam<LibraryResponse>(r => r.Title, "The title of the media library.");
|
||||
ResponseParam<LibraryResponse>(r => r.LibraryType, "The type of the media library.");
|
||||
ResponseParam<LibraryResponse>(r => r.ContentLocations, "The file system paths of the directories where the media library elements are located.");
|
||||
ResponseParam<LibraryResponse>(r => r.CoverImage, "The path of the image file used as the cover for the library.");
|
||||
ResponseParam<LibraryResponse>(r => r.CreatedOnUtc, "The date and time when the entity was created.");
|
||||
ResponseParam<LibraryResponse>(r => r.UpdatedOnUtc, "The date and time when the entity was last updated.");
|
||||
|
||||
@@ -44,6 +45,7 @@ public class GetLibraryEndpointSummary : Summary<GetLibraryEndpoint, GetLibraryR
|
||||
Title: "TV Shows",
|
||||
LibraryType: LibraryType.TvShow,
|
||||
ContentLocations: ["/media/tv shows/drama/", "/media/tv shows/SCI-FI/"],
|
||||
CoverImage: "/media/myPoster.jpg",
|
||||
CreatedOnUtc: DateTime.UtcNow,
|
||||
UpdatedOnUtc: default
|
||||
));
|
||||
@@ -124,6 +126,5 @@ public class GetLibraryEndpointSummary : Summary<GetLibraryEndpoint, GetLibraryR
|
||||
traceId = "00-2470be4248a2a5a0c6f70579975a6954-b9c3ba9544a03500-00"
|
||||
}
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
+1
-5
@@ -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 UpdateLibraryEndpoint : BaseEndpoint<UpdateLibraryRequest, IResult>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
public override async Task<IResult> ExecuteAsync(UpdateLibraryRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
// retrieve the currently authenticated user, and send it with the request
|
||||
string? user = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
ErrorOr<LibraryResponse> result = await _sender.Send(request.ToCommand(Guid.Parse(user!)), cancellationToken).ConfigureAwait(false);
|
||||
ErrorOr<LibraryResponse> result = await _sender.Send(request.ToCommand(), cancellationToken).ConfigureAwait(false);
|
||||
return result.Match(success => TypedResults.Ok(success), Problem);
|
||||
}
|
||||
}
|
||||
+5
-1
@@ -32,7 +32,8 @@ public class UpdateLibraryEndpointSummary : Summary<UpdateLibraryEndpoint, Updat
|
||||
ContentLocations: [
|
||||
"/media/tv shows/drama/",
|
||||
"/media/tv shows/SCI-FI/",
|
||||
]
|
||||
],
|
||||
CoverImage: "/media/posters/myPoster.jpg"
|
||||
);
|
||||
|
||||
RequestParam(r => r.Id, "The Id of the media library. Required.");
|
||||
@@ -40,12 +41,14 @@ public class UpdateLibraryEndpointSummary : Summary<UpdateLibraryEndpoint, Updat
|
||||
RequestParam(r => 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<LibraryResponse>(r => r.Id, "The unique identifier of the entity.");
|
||||
ResponseParam<LibraryResponse>(r => r.UserId, "The Id of the user owning the media library.");
|
||||
ResponseParam<LibraryResponse>(r => r.Title, "The title of the media library.");
|
||||
ResponseParam<LibraryResponse>(r => r.LibraryType, "The type of the media library.");
|
||||
ResponseParam<LibraryResponse>(r => r.ContentLocations, "The file system paths of the directories where the media library elements are located.");
|
||||
ResponseParam<LibraryResponse>(r => r.CoverImage, "The path of the image file used as the cover for the library.");
|
||||
ResponseParam<LibraryResponse>(r => r.CreatedOnUtc, "The date and time when the entity was created.");
|
||||
ResponseParam<LibraryResponse>(r => r.UpdatedOnUtc, "The date and time when the entity was last updated.");
|
||||
|
||||
@@ -57,6 +60,7 @@ public class UpdateLibraryEndpointSummary : Summary<UpdateLibraryEndpoint, Updat
|
||||
Title: "TV Shows",
|
||||
LibraryType: LibraryType.TvShow,
|
||||
ContentLocations: ["/media/tv shows/drama/", "/media/tv shows/SCI-FI/"],
|
||||
"/media/myPoster.jpg",
|
||||
CreatedOnUtc: DateTime.UtcNow,
|
||||
UpdatedOnUtc: default
|
||||
));
|
||||
|
||||
@@ -33,6 +33,11 @@ public class LibraryModel
|
||||
/// </summary>
|
||||
public string? LibraryType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the path of the image file used as the cover for the library.
|
||||
/// </summary>
|
||||
public string? CoverImage { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the collection of directories that contain the library files.
|
||||
/// </summary>
|
||||
|
||||
+27
@@ -78,6 +78,15 @@ namespace Lumina.Presentation.Web.Resources.Views.Library.Management {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Add image.
|
||||
/// </summary>
|
||||
public static string AddImage {
|
||||
get {
|
||||
return ResourceManager.GetString("AddImage", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Add New Library.
|
||||
/// </summary>
|
||||
@@ -177,6 +186,24 @@ namespace Lumina.Presentation.Web.Resources.Views.Library.Management {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Cover Image.
|
||||
/// </summary>
|
||||
public static string CoverImage {
|
||||
get {
|
||||
return ResourceManager.GetString("CoverImage", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Select the image file that will be used as the cover for this library.
|
||||
/// </summary>
|
||||
public static string DescriptionCover {
|
||||
get {
|
||||
return ResourceManager.GetString("DescriptionCover", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Select the folders containing the media files of this library.
|
||||
/// </summary>
|
||||
|
||||
@@ -123,6 +123,9 @@
|
||||
<data name="AddDirectory" xml:space="preserve">
|
||||
<value>Verzeichnis hinzufügen</value>
|
||||
</data>
|
||||
<data name="AddImage" xml:space="preserve">
|
||||
<value>Bild hinzufügen</value>
|
||||
</data>
|
||||
<data name="AddNewLibrary" xml:space="preserve">
|
||||
<value>Neue Bibliothek Hinzufügen</value>
|
||||
</data>
|
||||
@@ -156,6 +159,12 @@
|
||||
<data name="Cover" xml:space="preserve">
|
||||
<value>Coverversion</value>
|
||||
</data>
|
||||
<data name="CoverImage" xml:space="preserve">
|
||||
<value>Titelbild</value>
|
||||
</data>
|
||||
<data name="DescriptionCover" xml:space="preserve">
|
||||
<value>Wählen Sie die Bilddatei aus, die als Cover für diese Bibliothek verwendet wird</value>
|
||||
</data>
|
||||
<data name="DescriptionDirectories" xml:space="preserve">
|
||||
<value>Wählen Sie die Ordner mit den Mediendateien dieser Bibliothek aus</value>
|
||||
</data>
|
||||
|
||||
@@ -123,6 +123,9 @@
|
||||
<data name="AddDirectory" xml:space="preserve">
|
||||
<value>Add directory</value>
|
||||
</data>
|
||||
<data name="AddImage" xml:space="preserve">
|
||||
<value>Add image</value>
|
||||
</data>
|
||||
<data name="AddNewLibrary" xml:space="preserve">
|
||||
<value>Add New Library</value>
|
||||
</data>
|
||||
@@ -156,6 +159,12 @@
|
||||
<data name="Cover" xml:space="preserve">
|
||||
<value>Cover</value>
|
||||
</data>
|
||||
<data name="CoverImage" xml:space="preserve">
|
||||
<value>Cover Image</value>
|
||||
</data>
|
||||
<data name="DescriptionCover" xml:space="preserve">
|
||||
<value>Select the image file that will be used as the cover for this library</value>
|
||||
</data>
|
||||
<data name="DescriptionDirectories" xml:space="preserve">
|
||||
<value>Select the folders containing the media files of this library</value>
|
||||
</data>
|
||||
|
||||
@@ -123,6 +123,9 @@
|
||||
<data name="AddDirectory" xml:space="preserve">
|
||||
<value>Agregar directorio</value>
|
||||
</data>
|
||||
<data name="AddImage" xml:space="preserve">
|
||||
<value>Añadir imagen</value>
|
||||
</data>
|
||||
<data name="AddNewLibrary" xml:space="preserve">
|
||||
<value>Agregar Nueva Biblioteca</value>
|
||||
</data>
|
||||
@@ -156,6 +159,12 @@
|
||||
<data name="Cover" xml:space="preserve">
|
||||
<value>Versión</value>
|
||||
</data>
|
||||
<data name="CoverImage" xml:space="preserve">
|
||||
<value>Imagen De Portada</value>
|
||||
</data>
|
||||
<data name="DescriptionCover" xml:space="preserve">
|
||||
<value>Seleccione el archivo de imagen que se usará como portada para esta biblioteca</value>
|
||||
</data>
|
||||
<data name="DescriptionDirectories" xml:space="preserve">
|
||||
<value>Selecciona las carpetas que contienen los archivos multimedia de esta biblioteca</value>
|
||||
</data>
|
||||
|
||||
@@ -123,6 +123,9 @@
|
||||
<data name="AddDirectory" xml:space="preserve">
|
||||
<value>Ajouter un répertoire</value>
|
||||
</data>
|
||||
<data name="AddImage" xml:space="preserve">
|
||||
<value>Ajouter une image</value>
|
||||
</data>
|
||||
<data name="AddNewLibrary" xml:space="preserve">
|
||||
<value>Ajouter Une Nouvelle Bibliothèque</value>
|
||||
</data>
|
||||
@@ -156,6 +159,12 @@
|
||||
<data name="Cover" xml:space="preserve">
|
||||
<value>Reprise</value>
|
||||
</data>
|
||||
<data name="CoverImage" xml:space="preserve">
|
||||
<value>Image De Couverture</value>
|
||||
</data>
|
||||
<data name="DescriptionCover" xml:space="preserve">
|
||||
<value>Sélectionnez le fichier image qui servira de couverture pour cette bibliothèque</value>
|
||||
</data>
|
||||
<data name="DescriptionDirectories" xml:space="preserve">
|
||||
<value>Sélectionnez les dossiers contenant les fichiers multimédias de cette bibliothèque</value>
|
||||
</data>
|
||||
|
||||
@@ -123,6 +123,9 @@
|
||||
<data name="AddDirectory" xml:space="preserve">
|
||||
<value>Aggiungi directory</value>
|
||||
</data>
|
||||
<data name="AddImage" xml:space="preserve">
|
||||
<value>Aggiungi immagine</value>
|
||||
</data>
|
||||
<data name="AddNewLibrary" xml:space="preserve">
|
||||
<value>Aggiungi Nuova Libreria</value>
|
||||
</data>
|
||||
@@ -156,6 +159,12 @@
|
||||
<data name="Cover" xml:space="preserve">
|
||||
<value>Reinterpretazione</value>
|
||||
</data>
|
||||
<data name="CoverImage" xml:space="preserve">
|
||||
<value>Immagine Di Copertina</value>
|
||||
</data>
|
||||
<data name="DescriptionCover" xml:space="preserve">
|
||||
<value>Seleziona il file immagine che sarà utilizzato come copertina per questa libreria</value>
|
||||
</data>
|
||||
<data name="DescriptionDirectories" xml:space="preserve">
|
||||
<value>Seleziona le cartelle che contengono i file multimediali di questa biblioteca</value>
|
||||
</data>
|
||||
|
||||
@@ -123,6 +123,9 @@
|
||||
<data name="AddDirectory" xml:space="preserve">
|
||||
<value>ディレクトリを追加</value>
|
||||
</data>
|
||||
<data name="AddImage" xml:space="preserve">
|
||||
<value>画像を追加</value>
|
||||
</data>
|
||||
<data name="AddNewLibrary" xml:space="preserve">
|
||||
<value>新しい ライブラリ 追加</value>
|
||||
</data>
|
||||
@@ -156,6 +159,12 @@
|
||||
<data name="Cover" xml:space="preserve">
|
||||
<value>カバー曲</value>
|
||||
</data>
|
||||
<data name="CoverImage" xml:space="preserve">
|
||||
<value>カバー画像</value>
|
||||
</data>
|
||||
<data name="DescriptionCover" xml:space="preserve">
|
||||
<value>このライブラリのカバーとして使用する画像ファイルを選択してください</value>
|
||||
</data>
|
||||
<data name="DescriptionDirectories" xml:space="preserve">
|
||||
<value>このライブラリのメディアファイルを含むフォルダを選択してください</value>
|
||||
</data>
|
||||
|
||||
@@ -123,6 +123,9 @@
|
||||
<data name="AddDirectory" xml:space="preserve">
|
||||
<value>Add directory</value>
|
||||
</data>
|
||||
<data name="AddImage" xml:space="preserve">
|
||||
<value>Add image</value>
|
||||
</data>
|
||||
<data name="AddNewLibrary" xml:space="preserve">
|
||||
<value>Add New Library</value>
|
||||
</data>
|
||||
@@ -156,6 +159,12 @@
|
||||
<data name="Cover" xml:space="preserve">
|
||||
<value>Cover</value>
|
||||
</data>
|
||||
<data name="CoverImage" xml:space="preserve">
|
||||
<value>Cover Image</value>
|
||||
</data>
|
||||
<data name="DescriptionCover" xml:space="preserve">
|
||||
<value>Select the image file that will be used as the cover for this library</value>
|
||||
</data>
|
||||
<data name="DescriptionDirectories" xml:space="preserve">
|
||||
<value>Select the folders containing the media files of this library</value>
|
||||
</data>
|
||||
|
||||
@@ -123,6 +123,9 @@
|
||||
<data name="AddDirectory" xml:space="preserve">
|
||||
<value>Adaugă dosar</value>
|
||||
</data>
|
||||
<data name="AddImage" xml:space="preserve">
|
||||
<value>Adaugă imagine</value>
|
||||
</data>
|
||||
<data name="AddNewLibrary" xml:space="preserve">
|
||||
<value>Adaugă Bibliotecă Nouă</value>
|
||||
</data>
|
||||
@@ -156,6 +159,12 @@
|
||||
<data name="Cover" xml:space="preserve">
|
||||
<value>Preluare</value>
|
||||
</data>
|
||||
<data name="CoverImage" xml:space="preserve">
|
||||
<value>Imagine Copertă</value>
|
||||
</data>
|
||||
<data name="DescriptionCover" xml:space="preserve">
|
||||
<value>Selectează fișierul imagine care va fi folosit ca și copertă pentru această bibliotecă</value>
|
||||
</data>
|
||||
<data name="DescriptionDirectories" xml:space="preserve">
|
||||
<value>Selectează dosarele care conțin fișierele media ale acestei biblioteci</value>
|
||||
</data>
|
||||
|
||||
@@ -123,6 +123,9 @@
|
||||
<data name="AddDirectory" xml:space="preserve">
|
||||
<value>Добавить директорию</value>
|
||||
</data>
|
||||
<data name="AddImage" xml:space="preserve">
|
||||
<value>Добавить изображение</value>
|
||||
</data>
|
||||
<data name="AddNewLibrary" xml:space="preserve">
|
||||
<value>Добавить Новую Библиотеку</value>
|
||||
</data>
|
||||
@@ -156,6 +159,12 @@
|
||||
<data name="Cover" xml:space="preserve">
|
||||
<value>Кавер</value>
|
||||
</data>
|
||||
<data name="CoverImage" xml:space="preserve">
|
||||
<value>Обложка</value>
|
||||
</data>
|
||||
<data name="DescriptionCover" xml:space="preserve">
|
||||
<value>Выберите файл изображения, который будет использоваться в качестве обложки для этой библиотеки</value>
|
||||
</data>
|
||||
<data name="DescriptionDirectories" xml:space="preserve">
|
||||
<value>Выберите папки, содержащие медиафайлы этой библиотеки</value>
|
||||
</data>
|
||||
|
||||
@@ -123,6 +123,9 @@
|
||||
<data name="AddDirectory" xml:space="preserve">
|
||||
<value>添加目录</value>
|
||||
</data>
|
||||
<data name="AddImage" xml:space="preserve">
|
||||
<value>添加图片</value>
|
||||
</data>
|
||||
<data name="AddNewLibrary" xml:space="preserve">
|
||||
<value>添加 新库</value>
|
||||
</data>
|
||||
@@ -156,6 +159,12 @@
|
||||
<data name="Cover" xml:space="preserve">
|
||||
<value>翻唱</value>
|
||||
</data>
|
||||
<data name="CoverImage" xml:space="preserve">
|
||||
<value>封面图片</value>
|
||||
</data>
|
||||
<data name="DescriptionCover" xml:space="preserve">
|
||||
<value>选择将用作此库封面的图片文件</value>
|
||||
</data>
|
||||
<data name="DescriptionDirectories" xml:space="preserve">
|
||||
<value>选择包含该图书馆媒体文件的文件夹</value>
|
||||
</data>
|
||||
|
||||
@@ -103,6 +103,25 @@
|
||||
</div>
|
||||
<small class="form-label text-disabled form-description">@_localizer["DescriptionLibraryType"]</small>
|
||||
</div>
|
||||
<!-- Cover -->
|
||||
<div class="form-row mt-10">
|
||||
<div class="form-label">
|
||||
<label asp-for="CoverImage">@_localizer["CoverImage"]</label>:
|
||||
<img src="~/images/ui/add-file.svg" alt="@_localizer["AddImage"]" id="add-media-cover" title="@_localizer["AddImage"]" class="add-form-table-row-icon ml-5" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div id="add-media-cover-form-table" class="form-table w-100">
|
||||
@if (Model.CoverImage is not null)
|
||||
{
|
||||
<div class="form-table-row">
|
||||
<span title="@Model.CoverImage">@Model.CoverImage</span>
|
||||
<img src="~/images/ui/delete.svg" alt="@_localizer["Remove"]" title="@_localizer["Remove"]" class="remove-form-table-row-icon" />
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
<small class="form-label text-disabled form-description">@_localizer["DescriptionCover"]</small>
|
||||
</div>
|
||||
<!-- Directories -->
|
||||
<div class="form-row mt-10">
|
||||
<div class="form-label">
|
||||
@@ -112,7 +131,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="form-table w-100">
|
||||
<div id="add-media-directory-form-table" class="form-table w-100">
|
||||
@for (int i = 0; i < Model.ContentLocations.Count; i++)
|
||||
{
|
||||
<div class="form-table-row">
|
||||
@@ -131,8 +150,8 @@
|
||||
<!-- section success -->
|
||||
<div class="text-center w-100">
|
||||
<p id="save-success" class="text-light-one w-100 hidden">@_localizer["LibrarySaved"]</p>
|
||||
<button id="btn-back-to-libraries" type="button" class="abort-button h-22px w-150px mx-auto mt-10 hidden">@_localizer["BackToLibraries"]</button>
|
||||
<button id="btn-add-new-library" type="button" class="confirm-button h-22px w-150px mx-auto mt-10 hidden">@_localizer["AddNewLibrary"]</button>
|
||||
<button id="btn-back-to-libraries" type="button" class="abort-button h-22px w-180px mx-auto mt-10 hidden">@_localizer["BackToLibraries"]</button>
|
||||
<button id="btn-add-new-library" type="button" class="confirm-button h-22px w-180px mx-auto mt-10 hidden">@_localizer["AddNewLibrary"]</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -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', `
|
||||
<div class="form-table-row">
|
||||
<span title="${path}">${path}</span>
|
||||
<span title="${normalizedPath}">${normalizedPath}</span>
|
||||
<img src="/images/ui/delete.svg" alt="@_localizer["Remove"]" title="@_localizer["Remove"]" class="remove-form-table-row-icon" onclick="this.closest('.form-table-row').remove();" />
|
||||
</div>
|
||||
`);
|
||||
@@ -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', `
|
||||
<div class="form-table-row">
|
||||
<span title="${path}">${path}</span>
|
||||
<img src="/images/ui/delete.svg" alt="@_localizer["Remove"]" title="@_localizer["Remove"]" class="remove-form-table-row-icon" onclick="this.closest('.form-table-row').remove();" />
|
||||
</div>
|
||||
`);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 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
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<svg fill="#4AA747" width="800px" height="800px" viewBox="0 0 24 24" id="add-file-8" data-name="Flat Line" xmlns="http://www.w3.org/2000/svg" class="icon flat-line">
|
||||
<!-- Define a mask to cut out the plus sign -->
|
||||
<mask id="cut-out-plus">
|
||||
<!-- Make everything visible by default -->
|
||||
<rect width="24" height="24" fill="white"/>
|
||||
<!-- Cut out the longer plus sign (sharp corners) -->
|
||||
<path d="M8,12h8M12,8v8" style="stroke: black; stroke-width: 2; fill: none;"></path>
|
||||
</mask>
|
||||
|
||||
<!-- File shape with green fill and stroke, plus transparent cross -->
|
||||
<path
|
||||
d="M18,21a1,1,0,0,0,1-1V4a1,1,0,0,0-1-1H9L5,7V20a1,1,0,0,0,1,1Z"
|
||||
style="fill: #4AA747; stroke: #4AA747; stroke-linecap: round; stroke-linejoin: round; stroke-width: 2;"
|
||||
mask="url(#cut-out-plus)">
|
||||
</path>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 843 B |
+36
-12
@@ -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();
|
||||
}
|
||||
}
|
||||
+32
@@ -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();
|
||||
}
|
||||
}
|
||||
+41
-4
@@ -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<string> contentLocations =
|
||||
[
|
||||
"C:/Media/Books",
|
||||
"D:/Books"
|
||||
];
|
||||
|
||||
ErrorOr<Library> 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();
|
||||
}
|
||||
}
|
||||
+8
-5
@@ -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<LibraryType>(),
|
||||
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<string>? contentLocations = null)
|
||||
IEnumerable<string>? contentLocations = null,
|
||||
string? coverImage = null)
|
||||
{
|
||||
ErrorOr<Library> 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;
|
||||
|
||||
Reference in new issue
Block a user