Merge pull request #106 from BinaryAlley/feature/add-media-libraries-management-view

Adds media libraries management view
This commit is contained in:
BinaryAlley authored and GitHub committed 2025-01-11 23:25:40 +02:00
commit ecc332a91a
162 files changed
+3738 -168

No files matched your search

@@ -13,6 +13,6 @@ public interface IDeleteAllRepositoryAction
/// <summary> /// <summary>
/// Deletes all entities from the storage medium. /// Deletes all entities from the storage medium.
/// </summary> /// </summary>
/// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successfull operation, or an error.</returns> /// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successful operation, or an error.</returns>
Task<ErrorOr<Deleted>> DeleteAllAsync(); Task<ErrorOr<Deleted>> DeleteAllAsync();
} }
@@ -17,6 +17,6 @@ public interface IDeleteByIdRepositoryAction<TId> where TId : notnull
/// </summary> /// </summary>
/// <param name="id">The id of the element to be deleted.</param> /// <param name="id">The id of the element to be deleted.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param> /// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successfull operation, or an error.</returns> /// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successful operation, or an error.</returns>
Task<ErrorOr<Deleted>> DeleteByIdAsync(TId id, CancellationToken cancellationToken); Task<ErrorOr<Deleted>> DeleteByIdAsync(TId id, CancellationToken cancellationToken);
} }
@@ -18,6 +18,6 @@ public interface IInsertRepositoryAction<TModel> where TModel : IStorageEntity
/// </summary> /// </summary>
/// <param name="data">The element to be saved.</param> /// <param name="data">The element to be saved.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param> /// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successfull operation, or an error.</returns> /// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successful operation, or an error.</returns>
Task<ErrorOr<Created>> InsertAsync(TModel data, CancellationToken cancellationToken); Task<ErrorOr<Created>> InsertAsync(TModel data, CancellationToken cancellationToken);
} }
@@ -18,6 +18,6 @@ public interface IUpdateRepositoryAction<TModel> where TModel : IStorageEntity
/// </summary> /// </summary>
/// <param name="data">The element that will be updated.</param> /// <param name="data">The element that will be updated.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param> /// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successfull operation, or an error.</returns> /// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successful operation, or an error.</returns>
Task<ErrorOr<Updated>> UpdateAsync(TModel data, CancellationToken cancellationToken); Task<ErrorOr<Updated>> UpdateAsync(TModel data, CancellationToken cancellationToken);
} }
@@ -12,7 +12,9 @@ namespace Lumina.Application.Common.DataAccess.Repositories.MediaLibrary;
/// </summary> /// </summary>
public interface ILibraryRepository : IRepository<LibraryEntity>, public interface ILibraryRepository : IRepository<LibraryEntity>,
IGetByIdRepositoryAction<LibraryEntity, Guid>, IGetByIdRepositoryAction<LibraryEntity, Guid>,
IGetAllRepositoryAction<LibraryEntity>,
IInsertRepositoryAction<LibraryEntity>, IInsertRepositoryAction<LibraryEntity>,
IUpdateRepositoryAction<LibraryEntity> IUpdateRepositoryAction<LibraryEntity>,
IDeleteByIdRepositoryAction<Guid>
{ {
} }
@@ -17,7 +17,7 @@ public interface IDataSeedService
/// </summary> /// </summary>
/// <param name="adminId">The Id of the admin admin user who will own these permissions.</param> /// <param name="adminId">The Id of the admin admin user who will own these permissions.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param> /// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successfull operation, or an error.</returns> /// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successful operation, or an error.</returns>
Task<ErrorOr<Created>> SetDefaultAuthorizationPermissionsAsync(Guid adminId, CancellationToken cancellationToken); Task<ErrorOr<Created>> SetDefaultAuthorizationPermissionsAsync(Guid adminId, CancellationToken cancellationToken);
/// <summary> /// <summary>
@@ -25,7 +25,7 @@ public interface IDataSeedService
/// </summary> /// </summary>
/// <param name="userId">The Id of the admin user for whom roles will be set.</param> /// <param name="userId">The Id of the admin user for whom roles will be set.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param> /// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successfull operation, or an error.</returns> /// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successful operation, or an error.</returns>
Task<ErrorOr<Created>> SetDefaultAuthorizationRolesAsync(Guid userId, CancellationToken cancellationToken); Task<ErrorOr<Created>> SetDefaultAuthorizationRolesAsync(Guid userId, CancellationToken cancellationToken);
/// <summary> /// <summary>
@@ -33,7 +33,7 @@ public interface IDataSeedService
/// </summary> /// </summary>
/// <param name="userId">The Id of the admin user to receive admin role permissions.</param> /// <param name="userId">The Id of the admin user to receive admin role permissions.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param> /// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successfull operation, or an error.</returns> /// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successful operation, or an error.</returns>
Task<ErrorOr<Created>> SetAdminRolePermissionsAsync(Guid userId, CancellationToken cancellationToken); Task<ErrorOr<Created>> SetAdminRolePermissionsAsync(Guid userId, CancellationToken cancellationToken);
/// <summary> /// <summary>
@@ -41,6 +41,6 @@ public interface IDataSeedService
/// </summary> /// </summary>
/// <param name="userId">The Id of the admin user to receive the admin role.</param> /// <param name="userId">The Id of the admin user to receive the admin role.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param> /// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successfull operation, or an error.</returns> /// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successful operation, or an error.</returns>
Task<ErrorOr<Created>> SetAdminRoleToAdministratorAccount(Guid userId, CancellationToken cancellationToken); Task<ErrorOr<Created>> SetAdminRoleToAdministratorAccount(Guid userId, CancellationToken cancellationToken);
} }
@@ -26,7 +26,7 @@ public class DomainEventsQueue : IDomainEventsQueue
/// </summary> /// </summary>
/// <param name="domainEvent">When this method returns, contains the domain event removed from the queue, or the default value of <see cref="IDomainEvent"/> if the queue is empty. /// <param name="domainEvent">When this method returns, contains the domain event removed from the queue, or the default value of <see cref="IDomainEvent"/> if the queue is empty.
/// </param> /// </param>
/// <returns><see langword="true"/> if a domain event was successfully dequeued, <see langword="false"/> otherwise.</returns> /// <returns><see langword="true"/> if a domain event was successfuly dequeued, <see langword="false"/> otherwise.</returns>
public bool TryDequeue(out IDomainEvent domainEvent) public bool TryDequeue(out IDomainEvent domainEvent)
{ {
return _queue.TryDequeue(out domainEvent!); return _queue.TryDequeue(out domainEvent!);
@@ -20,6 +20,6 @@ public interface IDomainEventsQueue
/// </summary> /// </summary>
/// <param name="domainEvent">When this method returns, contains the domain event removed from the queue, or the default value of <see cref="IDomainEvent"/> if the queue is empty. /// <param name="domainEvent">When this method returns, contains the domain event removed from the queue, or the default value of <see cref="IDomainEvent"/> if the queue is empty.
/// </param> /// </param>
/// <returns><see langword="true"/> if a domain event was successfully dequeued, <see langword="false"/> otherwise.</returns> /// <returns><see langword="true"/> if a domain event was successfuly dequeued, <see langword="false"/> otherwise.</returns>
bool TryDequeue(out IDomainEvent domainEvent); bool TryDequeue(out IDomainEvent domainEvent);
} }
@@ -0,0 +1,24 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Core.MediaLibrary.Management.Commands.DeleteLibrary;
using Lumina.Contracts.Requests.MediaLibrary.Management;
#endregion
namespace Lumina.Application.Common.Mapping.MediaLibrary.Management;
/// <summary>
/// Extension methods for converting <see cref="DeleteLibraryRequest"/>.
/// </summary>
public static class DeleteLibraryRequestMapping
{
/// <summary>
/// Converts <paramref name="request"/> to <see cref="DeleteLibraryCommand"/>.
/// </summary>
/// <param name="request">The request to be converted.</param>
/// <returns>The converted command.</returns>
public static DeleteLibraryCommand ToCommand(this DeleteLibraryRequest request)
{
return new DeleteLibraryCommand(
request.Id
);
}
}
@@ -1,5 +1,5 @@
#region ========================================================================= USING ===================================================================================== #region ========================================================================= USING =====================================================================================
using Lumina.Application.Core.MediaLibrary.Management.Queries; using Lumina.Application.Core.MediaLibrary.Management.Queries.GetLibrary;
using Lumina.Contracts.Requests.MediaLibrary.Management; using Lumina.Contracts.Requests.MediaLibrary.Management;
using System; using System;
#endregion #endregion
@@ -15,13 +15,11 @@ public static class GetLibraryRequestMapping
/// Converts <paramref name="request"/> to <see cref="GetLibraryQuery"/>. /// Converts <paramref name="request"/> to <see cref="GetLibraryQuery"/>.
/// </summary> /// </summary>
/// <param name="request">The request to be converted.</param> /// <param name="request">The request to be converted.</param>
/// <param name="userId">The Id of the user requesting the media library.</param>
/// <returns>The converted query.</returns> /// <returns>The converted query.</returns>
public static GetLibraryQuery ToQuery(this GetLibraryRequest request, Guid userId) public static GetLibraryQuery ToQuery(this GetLibraryRequest request)
{ {
return new GetLibraryQuery( return new GetLibraryQuery(
request.Id, request.Id
userId
); );
} }
} }
@@ -1,6 +1,9 @@
#region ========================================================================= USING ===================================================================================== #region ========================================================================= USING =====================================================================================
using ErrorOr;
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management; using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management;
using Lumina.Contracts.Responses.MediaLibrary.Management; using Lumina.Contracts.Responses.MediaLibrary.Management;
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate;
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
using System.Linq; using System.Linq;
#endregion #endregion
@@ -29,4 +32,21 @@ public static class LibraryEntityMapping
repositoryEntity.UpdatedOnUtc repositoryEntity.UpdatedOnUtc
); );
} }
/// <summary>
/// Converts <paramref name="repositoryEntity"/> to <see cref="Library"/>.
/// </summary>
/// <param name="repositoryEntity">The repository entity to be converted.</param>
/// <returns>The converted domain entity.</returns>
public static ErrorOr<Library> ToDomainEntity(this LibraryEntity repositoryEntity)
{
return Library.Create(
LibraryId.Create(repositoryEntity.Id),
repositoryEntity.UserId,
repositoryEntity.Title,
repositoryEntity.LibraryType,
repositoryEntity.ContentLocations.Select(contentLocation => contentLocation.Path),
repositoryEntity.CoverImage
);
}
} }
@@ -30,7 +30,7 @@ public static class BookEntityMapping
/// </summary> /// </summary>
/// <param name="repositoryEntity">The repository entity to be converted.</param> /// <param name="repositoryEntity">The repository entity to be converted.</param>
/// <returns> /// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully converted <see cref="Book"/>, or an error message. /// An <see cref="ErrorOr{TValue}"/> containing either a successfuly converted <see cref="Book"/>, or an error message.
/// </returns> /// </returns>
public static ErrorOr<Book> ToDomainEntity(this BookEntity repositoryEntity) public static ErrorOr<Book> ToDomainEntity(this BookEntity repositoryEntity)
{ {
@@ -137,7 +137,7 @@ public static class BookEntityMapping
/// <param name="repositoryEntities">The repository entities to be converted.</param> /// <param name="repositoryEntities">The repository entities to be converted.</param>
/// <returns>The converted domain entities.</returns> /// <returns>The converted domain entities.</returns>
/// <returns> /// <returns>
/// An colection of <see cref="ErrorOr{TValue}"/> containing either successfully converted <see cref="Book"/>, or error messages. /// An colection of <see cref="ErrorOr{TValue}"/> containing either successfuly converted <see cref="Book"/>, or error messages.
/// </returns> /// </returns>
public static IEnumerable<ErrorOr<Book>> ToDomainEntities(this IEnumerable<BookEntity> repositoryEntities) public static IEnumerable<ErrorOr<Book>> ToDomainEntities(this IEnumerable<BookEntity> repositoryEntities)
{ {
@@ -19,7 +19,7 @@ public static class IsbnDtoMapping
/// </summary> /// </summary>
/// <param name="dto">The DTO to be converted.</param> /// <param name="dto">The DTO to be converted.</param>
/// <returns> /// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully converted <see cref="Isbn"/>, or an error message. /// An <see cref="ErrorOr{TValue}"/> containing either a successfuly converted <see cref="Isbn"/>, or an error message.
/// </returns> /// </returns>
public static ErrorOr<Isbn> ToDomainEntity(this IsbnDto dto) public static ErrorOr<Isbn> ToDomainEntity(this IsbnDto dto)
{ {
@@ -44,7 +44,7 @@ public class AddRoleCommandHandler : IRequestHandler<AddRoleCommand, ErrorOr<Rol
/// <param name="request">The request to be handled.</param> /// <param name="request">The request to be handled.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param> /// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns> /// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="RoleResponse"/>, or an error message. /// An <see cref="ErrorOr{TValue}"/> containing either a successfuly created <see cref="RoleResponse"/>, or an error message.
/// </returns> /// </returns>
public async ValueTask<ErrorOr<RolePermissionsResponse>> Handle(AddRoleCommand request, CancellationToken cancellationToken) public async ValueTask<ErrorOr<RolePermissionsResponse>> Handle(AddRoleCommand request, CancellationToken cancellationToken)
{ {
@@ -46,7 +46,7 @@ public class DeleteRoleCommandHandler : IRequestHandler<DeleteRoleCommand, Error
/// <param name="request">The request to be handled.</param> /// <param name="request">The request to be handled.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param> /// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns> /// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully deleted <see cref="RoleResponse"/>, or an error message. /// An <see cref="ErrorOr{TValue}"/> containing either a successfuly deleted <see cref="RoleResponse"/>, or an error message.
/// </returns> /// </returns>
public async ValueTask<ErrorOr<Deleted>> Handle(DeleteRoleCommand request, CancellationToken cancellationToken) public async ValueTask<ErrorOr<Deleted>> Handle(DeleteRoleCommand request, CancellationToken cancellationToken)
{ {
@@ -44,7 +44,7 @@ public class UpdateRoleCommandHandler : IRequestHandler<UpdateRoleCommand, Error
/// <param name="request">The request to be handled.</param> /// <param name="request">The request to be handled.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param> /// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns> /// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully updated <see cref="RoleResponse"/>, or an error message. /// An <see cref="ErrorOr{TValue}"/> containing either a successfuly updated <see cref="RoleResponse"/>, or an error message.
/// </returns> /// </returns>
public async ValueTask<ErrorOr<RolePermissionsResponse>> Handle(UpdateRoleCommand request, CancellationToken cancellationToken) public async ValueTask<ErrorOr<RolePermissionsResponse>> Handle(UpdateRoleCommand request, CancellationToken cancellationToken)
{ {
@@ -66,7 +66,7 @@ public class SetupApplicationCommandHandler : IRequestHandler<SetupApplicationCo
/// <param name="request">The request to be handled.</param> /// <param name="request">The request to be handled.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param> /// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns> /// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="RegistrationResponse"/>, or an error message. /// An <see cref="ErrorOr{TValue}"/> containing either a successfuly created <see cref="RegistrationResponse"/>, or an error message.
/// </returns> /// </returns>
public async ValueTask<ErrorOr<RegistrationResponse>> Handle(SetupApplicationCommand request, CancellationToken cancellationToken) public async ValueTask<ErrorOr<RegistrationResponse>> Handle(SetupApplicationCommand request, CancellationToken cancellationToken)
{ {
@@ -64,7 +64,7 @@ public class AddLibraryCommandHandler : IRequestHandler<AddLibraryCommand, Error
/// <param name="request">The request to be handled.</param> /// <param name="request">The request to be handled.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param> /// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns> /// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="LibraryResponse"/>, or an error message. /// An <see cref="ErrorOr{TValue}"/> containing either a successfuly created <see cref="LibraryResponse"/>, or an error message.
/// </returns> /// </returns>
public async ValueTask<ErrorOr<LibraryResponse>> Handle(AddLibraryCommand request, CancellationToken cancellationToken) public async ValueTask<ErrorOr<LibraryResponse>> Handle(AddLibraryCommand request, CancellationToken cancellationToken)
{ {
@@ -93,7 +93,7 @@ public class AddLibraryCommandHandler : IRequestHandler<AddLibraryCommand, Error
// if the user that made the request is not an Admin or they don't have the permission to manage media libraries, they do not have the right to create it // if the user that made the request is not an Admin or they don't have the permission to manage media libraries, they do not have the right to create it
if (!await _authorizationService.IsInRoleAsync(_currentUserService.UserId!.Value, "Admin", cancellationToken).ConfigureAwait(false) && if (!await _authorizationService.IsInRoleAsync(_currentUserService.UserId!.Value, "Admin", cancellationToken).ConfigureAwait(false) &&
!await _authorizationService.HasPermissionAsync(_currentUserService.UserId!.Value, AuthorizationPermission.canCreateLibraries, cancellationToken).ConfigureAwait(false)) !await _authorizationService.HasPermissionAsync(_currentUserService.UserId!.Value, AuthorizationPermission.CanCreateLibraries, cancellationToken).ConfigureAwait(false))
return ApplicationErrors.Authorization.NotAuthorized; return ApplicationErrors.Authorization.NotAuthorized;
if (createLibraryResult.IsError) if (createLibraryResult.IsError)
@@ -0,0 +1,17 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using Mediator;
using System;
using System.Diagnostics;
#endregion
namespace Lumina.Application.Core.MediaLibrary.Management.Commands.DeleteLibrary;
/// <summary>
/// Command for deleting a media library by its Id.
/// </summary>
/// <param name="Id">The Id of the media library to delete.</param>
[DebuggerDisplay("Id: {Id}")]
public record DeleteLibraryCommand(
Guid Id
) : IRequest<ErrorOr<Deleted>>;
@@ -0,0 +1,96 @@
#region ========================================================================= USING =====================================================================================
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.DomainEvents;
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.Events;
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate;
using Mediator;
using System.Threading;
using System.Threading.Tasks;
using ApplicationErrors = Lumina.Application.Common.Errors.Errors;
using DomainErrors = Lumina.Domain.Common.Errors.Errors;
#endregion
namespace Lumina.Application.Core.MediaLibrary.Management.Commands.DeleteLibrary;
/// <summary>
/// Handler for the command to delete a library by its Id.
/// </summary>
public class DeleteLibraryCommandHandler : IRequestHandler<DeleteLibraryCommand, ErrorOr<Deleted>>
{
private readonly IUnitOfWork _unitOfWork;
private readonly ICurrentUserService _currentUserService;
private readonly IAuthorizationService _authorizationService;
private readonly IDomainEventsQueue _domainEventsQueue;
/// <summary>
/// Initializes a new instance of the <see cref="DeleteLibraryCommandHandler"/> 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="domainEventsQueue">Injected service for the queue of domain events.</param>
/// <param name="unitOfWork">Injected unit of work for interacting with the data access layer repositories.</param>
public DeleteLibraryCommandHandler(
IAuthorizationService authorizationService,
ICurrentUserService currentUserService,
IDomainEventsQueue domainEventsQueue,
IUnitOfWork unitOfWork)
{
_authorizationService = authorizationService;
_currentUserService = currentUserService;
_domainEventsQueue = domainEventsQueue;
_unitOfWork = unitOfWork;
}
/// <summary>
/// Handles the command to delete a library by its Id.
/// </summary>
/// <param name="request">The request to be handled.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfuly created <see cref="LibraryResponse"/>, or an error message.
/// </returns>
public async ValueTask<ErrorOr<Deleted>> Handle(DeleteLibraryCommand request, CancellationToken cancellationToken)
{
// get the library with the specified id from the repository
ILibraryRepository libraryRepository = _unitOfWork.GetRepository<ILibraryRepository>();
ErrorOr<LibraryEntity?> getLibraryResult = await libraryRepository.GetByIdAsync(request.Id, cancellationToken).ConfigureAwait(false);
if (getLibraryResult.IsError)
return getLibraryResult.Errors;
else if (getLibraryResult.Value is null)
return DomainErrors.Library.LibraryNotFound;
// if the user that wants to delete the library is not an Admin or is not the owner of the library, they do not have the right to delete it
if (getLibraryResult.Value.UserId != _currentUserService.UserId ||
!await _authorizationService.IsInRoleAsync(_currentUserService.UserId!.Value, "Admin", cancellationToken).ConfigureAwait(false))
return ApplicationErrors.Authorization.NotAuthorized;
// create a domain library object
ErrorOr<Library> createLibraryResult = getLibraryResult.Value.ToDomainEntity();
if (createLibraryResult.IsError)
return createLibraryResult.Errors;
// delete the domain aggregate
ErrorOr<Deleted> deleteDomainLibraryResult = createLibraryResult.Value.Delete();
if (deleteDomainLibraryResult.IsError)
return deleteDomainLibraryResult.Errors;
// queue any domain events
foreach (IDomainEvent domainEvent in createLibraryResult.Value.PopDomainEvents())
_domainEventsQueue.Enqueue(domainEvent);
// perform the deletion
ErrorOr<Deleted> deletePersistenceLibraryResult = await libraryRepository.DeleteByIdAsync(request.Id, cancellationToken).ConfigureAwait(false);
if (deletePersistenceLibraryResult.IsError)
return deletePersistenceLibraryResult.Errors;
await _unitOfWork.SaveChangesAsync(cancellationToken).ConfigureAwait(false);
return deletePersistenceLibraryResult;
}
}
@@ -0,0 +1,23 @@
#region ========================================================================= USING =====================================================================================
using FluentValidation;
using Lumina.Domain.Common.Errors;
using System;
#endregion
namespace Lumina.Application.Core.MediaLibrary.Management.Commands.DeleteLibrary;
/// <summary>
/// Validates the needed validation rules for <see cref="DeleteLibraryCommand"/>.
/// </summary>
public class DeleteLibraryCommandValidator : AbstractValidator<DeleteLibraryCommand>
{
/// <summary>
/// Initializes a new instance of the <see cref="DeleteLibraryCommandValidator"/> class.
/// </summary>
public DeleteLibraryCommandValidator()
{
RuleFor(x => x.Id)
.NotEmpty().WithMessage(Errors.Library.LibraryIdCannotBeEmpty.Description)
.Must(id => id != Guid.Empty).WithMessage(Errors.Library.LibraryIdCannotBeEmpty.Description);
}
}
@@ -65,7 +65,7 @@ public class UpdateLibraryCommandHandler : IRequestHandler<UpdateLibraryCommand,
/// <param name="request">The request to be handled.</param> /// <param name="request">The request to be handled.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param> /// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns> /// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully updated <see cref="LibraryResponse"/>, or an error message. /// An <see cref="ErrorOr{TValue}"/> containing either a successfuly updated <see cref="LibraryResponse"/>, or an error message.
/// </returns> /// </returns>
public async ValueTask<ErrorOr<LibraryResponse>> Handle(UpdateLibraryCommand request, CancellationToken cancellationToken) public async ValueTask<ErrorOr<LibraryResponse>> Handle(UpdateLibraryCommand request, CancellationToken cancellationToken)
{ {
@@ -93,7 +93,7 @@ public class UpdateLibraryCommandHandler : IRequestHandler<UpdateLibraryCommand,
// 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 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 != _currentUserService.UserId || if (getLibraryResult.Value.UserId != _currentUserService.UserId ||
(!await _authorizationService.IsInRoleAsync(_currentUserService.UserId!.Value, "Admin", cancellationToken).ConfigureAwait(false) && (!await _authorizationService.IsInRoleAsync(_currentUserService.UserId!.Value, "Admin", cancellationToken).ConfigureAwait(false) &&
!await _authorizationService.HasPermissionAsync(_currentUserService.UserId!.Value, AuthorizationPermission.canCreateLibraries, cancellationToken))) !await _authorizationService.HasPermissionAsync(_currentUserService.UserId!.Value, AuthorizationPermission.CanCreateLibraries, cancellationToken)))
return ApplicationErrors.Authorization.NotAuthorized; return ApplicationErrors.Authorization.NotAuthorized;
// create a domain library object // create a domain library object
@@ -0,0 +1,88 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using Lumina.Application.Common.Infrastructure.Models.Configuration;
using Lumina.Domain.Common.Exceptions;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Services;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Strategies.Environment;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.Events;
using Mediator;
using Microsoft.Extensions.Options;
using System;
using System.Threading;
using System.Threading.Tasks;
#endregion
namespace Lumina.Application.Core.MediaLibrary.Management.Events;
/// <summary>
/// Handler for the event raised when a media library is deleted.
/// </summary>
public class LibraryDeletedDomainEventHandler : INotificationHandler<LibraryDeletedDomainEvent>
{
private readonly IEnvironmentContext _environmentContext;
private readonly IPathService _pathService;
private readonly MediaSettingsModel _mediaSettingsModel;
/// <summary>
/// Initializes a new instance of the <see cref="LibraryDeletedDomainEventHandler"/> class.
/// </summary>
/// <param name="environmentContext">Injected facade service for environment contextual services.</param>
/// <param name="pathService">Injected service for handling file system paths.</param>
/// <param name="mediaSettingsModelOptions">Injected service for retrieving <see cref="MediaSettingsModel"/>.</param>
public LibraryDeletedDomainEventHandler(IEnvironmentContext environmentContext, IPathService pathService, IOptions<MediaSettingsModel> mediaSettingsModelOptions)
{
_environmentContext = environmentContext;
_pathService = pathService;
_mediaSettingsModel = mediaSettingsModelOptions.Value;
}
/// <summary>
/// Handles the event raised when a media library is deleted.
/// </summary>
/// <param name="domainEvent">The domain event to be handled.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
public ValueTask Handle(LibraryDeletedDomainEvent domainEvent, CancellationToken cancellationToken)
{
// delete the media library directory in the internal location for media library files
ErrorOr<string> libraryPathResult = GetLibraryPath(domainEvent.Library.Id.Value);
if (libraryPathResult.IsError)
throw new EventualConsistencyException(libraryPathResult.FirstError, libraryPathResult.Errors);
ErrorOr<FileSystemPathId> newLibraryPathIdResult = FileSystemPathId.Create(libraryPathResult.Value);
if (newLibraryPathIdResult.IsError)
throw new EventualConsistencyException(newLibraryPathIdResult.FirstError, newLibraryPathIdResult.Errors);
ErrorOr<Deleted> deleteLibraryDirectoryResult = _environmentContext.DirectoryProviderService.DeleteDirectory(newLibraryPathIdResult.Value);
if (deleteLibraryDirectoryResult.IsError)
throw new EventualConsistencyException(deleteLibraryDirectoryResult.FirstError, deleteLibraryDirectoryResult.Errors);
return ValueTask.CompletedTask;
}
/// <summary>
/// Gets the file system path of a media library identified by <paramref name="libraryId"/>.
/// </summary>
/// <param name="libraryId">The id of the media library for which to regtrieve the file system path.</param>
/// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either the file system path of the media library, or an error message.
/// </returns>
private ErrorOr<string> GetLibraryPath(Guid libraryId)
{
// root directory for media
ErrorOr<string> rootPathResult = _pathService.CombinePath(AppContext.BaseDirectory, _mediaSettingsModel.RootDirectory);
if (rootPathResult.IsError)
return rootPathResult.Errors;
// libraries directory
ErrorOr<string> librariesPathResult = _pathService.CombinePath(rootPathResult.Value, _mediaSettingsModel.LibrariesDirectory);
if (librariesPathResult.IsError)
return librariesPathResult.Errors;
// this new particular library' directory
ErrorOr<string> libraryPathResult = _pathService.CombinePath(librariesPathResult.Value, libraryId.ToString());
if (libraryPathResult.IsError)
return libraryPathResult.Errors;
return libraryPathResult.Value;
}
}
@@ -33,7 +33,7 @@ public class LibrarySavedDomainEventHandler : INotificationHandler<LibrarySavedD
private readonly MediaSettingsModel _mediaSettingsModel; private readonly MediaSettingsModel _mediaSettingsModel;
/// <summary> /// <summary>
/// /// Initializes a new instance of the <see cref="LibrarySavedDomainEventHandler"/> class.
/// </summary> /// </summary>
/// <param name="unitOfWork">Injected unit of work for interacting with the data access layer repositories.</param> /// <param name="unitOfWork">Injected unit of work for interacting with the data access layer repositories.</param>
/// <param name="environmentContext">Injected facade service for environment contextual services.</param> /// <param name="environmentContext">Injected facade service for environment contextual services.</param>
@@ -192,7 +192,7 @@ public class LibrarySavedDomainEventHandler : INotificationHandler<LibrarySavedD
if (renameFileResult.IsError) if (renameFileResult.IsError)
return renameFileResult.Errors; return renameFileResult.Errors;
return renameFileResult.Value.Path; return $"cover.{imageCheckResult.Value.ToString().ToLower()}";
} }
/// <summary> /// <summary>
@@ -0,0 +1,12 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using Lumina.Contracts.Responses.MediaLibrary.Management;
using Mediator;
#endregion
namespace Lumina.Application.Core.MediaLibrary.Management.Queries.GetLibraries;
/// <summary>
/// Query for getting the list of media libraries.
/// </summary>
public record GetLibrariesQuery : IRequest<ErrorOr<LibraryResponse[]>>;
@@ -0,0 +1,73 @@
#region ========================================================================= USING =====================================================================================
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 Mediator;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
#endregion
namespace Lumina.Application.Core.MediaLibrary.Management.Queries.GetLibraries;
/// <summary>
/// Handler for the query to authenticate an account.
/// </summary>
public class GetLibrariesQueryHandler : IRequestHandler<GetLibrariesQuery, ErrorOr<LibraryResponse[]>>
{
private readonly IUnitOfWork _unitOfWork;
private readonly ICurrentUserService _currentUserService;
private readonly IAuthorizationService _authorizationService;
/// <summary>
/// Initializes a new instance of the <see cref="GetLibrariesQueryHandler"/> 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 GetLibrariesQueryHandler(
IAuthorizationService authorizationService,
ICurrentUserService currentUserService,
IUnitOfWork unitOfWork)
{
_authorizationService = authorizationService;
_currentUserService = currentUserService;
_unitOfWork = unitOfWork;
}
/// <summary>
/// Handles the query to authenticate an account.
/// </summary>
/// <param name="request">The request to be handled.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfuly created <see cref="LibraryResponse"/>, or an error message.
/// </returns>
public async ValueTask<ErrorOr<LibraryResponse[]>> Handle(GetLibrariesQuery request, CancellationToken cancellationToken)
{
// get the library with the specified id from the repository
ILibraryRepository libraryRepository = _unitOfWork.GetRepository<ILibraryRepository>();
ErrorOr<IEnumerable<LibraryEntity>> getLibrariesResult = await libraryRepository.GetAllAsync(cancellationToken).ConfigureAwait(false);
if (getLibrariesResult.IsError)
return getLibrariesResult.Errors;
// admins can see all libraries
if (await _authorizationService.IsInRoleAsync(_currentUserService.UserId!.Value, "Admin", cancellationToken).ConfigureAwait(false))
return ErrorOrFactory.From(getLibrariesResult.Value.Select(library => library.ToResponse()).ToArray());
else
{
// for regular users, only take the libraries that belong to them
LibraryResponse[] userLibraries = getLibrariesResult.Value
.Where(library => library.UserId == _currentUserService.UserId)
.Select(library => library.ToResponse()).ToArray();
return ErrorOrFactory.From(userLibraries);
}
}
}
@@ -6,15 +6,13 @@ using System;
using System.Diagnostics; using System.Diagnostics;
#endregion #endregion
namespace Lumina.Application.Core.MediaLibrary.Management.Queries; namespace Lumina.Application.Core.MediaLibrary.Management.Queries.GetLibrary;
/// <summary> /// <summary>
/// Query for getting a media library by its Id. /// Query for getting a media library by its Id.
/// </summary> /// </summary>
/// <param name="Id">The Id of the media library to get.</param> /// <param name="Id">The Id of the media library to get.</param>
/// <param name="UserId">The Id of the user requesting the media library.</param>
[DebuggerDisplay("Id: {Id}")] [DebuggerDisplay("Id: {Id}")]
public record GetLibraryQuery( public record GetLibraryQuery(
Guid Id, Guid Id
Guid UserId
) : IRequest<ErrorOr<LibraryResponse>>; ) : IRequest<ErrorOr<LibraryResponse>>;
@@ -3,8 +3,11 @@ using ErrorOr;
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management; using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management;
using Lumina.Application.Common.DataAccess.Repositories.MediaLibrary; using Lumina.Application.Common.DataAccess.Repositories.MediaLibrary;
using Lumina.Application.Common.DataAccess.UoW; 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.Application.Common.Mapping.MediaLibrary.Management;
using Lumina.Contracts.Responses.MediaLibrary.Management; using Lumina.Contracts.Responses.MediaLibrary.Management;
using Lumina.Domain.Common.Enums.Authorization;
using Mediator; using Mediator;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
@@ -12,44 +15,57 @@ using ApplicationErrors = Lumina.Application.Common.Errors.Errors;
using DomainErrors = Lumina.Domain.Common.Errors.Errors; using DomainErrors = Lumina.Domain.Common.Errors.Errors;
#endregion #endregion
namespace Lumina.Application.Core.MediaLibrary.Management.Queries; namespace Lumina.Application.Core.MediaLibrary.Management.Queries.GetLibrary;
/// <summary> /// <summary>
/// Handler for the query to authenticate an account. /// Handler for the query to get a library by its Id.
/// </summary> /// </summary>
public class GetLibraryQueryHandler : IRequestHandler<GetLibraryQuery, ErrorOr<LibraryResponse>> public class GetLibraryQueryHandler : IRequestHandler<GetLibraryQuery, ErrorOr<LibraryResponse>>
{ {
private readonly IUnitOfWork _unitOfWork; private readonly IUnitOfWork _unitOfWork;
private readonly ICurrentUserService _currentUserService;
private readonly IAuthorizationService _authorizationService;
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="GetLibraryQueryHandler"/> class. /// Initializes a new instance of the <see cref="GetLibraryQueryHandler"/> class.
/// </summary> /// </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> /// <param name="unitOfWork">Injected unit of work for interacting with the data access layer repositories.</param>
public GetLibraryQueryHandler( public GetLibraryQueryHandler(
IAuthorizationService authorizationService,
ICurrentUserService currentUserService,
IUnitOfWork unitOfWork) IUnitOfWork unitOfWork)
{ {
_authorizationService = authorizationService;
_currentUserService = currentUserService;
_unitOfWork = unitOfWork; _unitOfWork = unitOfWork;
} }
/// <summary> /// <summary>
/// Handles the query to authenticate an account. /// Handles the query to get a library by its Id.
/// </summary> /// </summary>
/// <param name="request">The request to be handled.</param> /// <param name="request">The request to be handled.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param> /// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns> /// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="LibraryResponse"/>, or an error message. /// An <see cref="ErrorOr{TValue}"/> containing either a successfuly created <see cref="LibraryResponse"/>, or an error message.
/// </returns> /// </returns>
public async ValueTask<ErrorOr<LibraryResponse>> Handle(GetLibraryQuery request, CancellationToken cancellationToken) public async ValueTask<ErrorOr<LibraryResponse>> Handle(GetLibraryQuery request, CancellationToken cancellationToken)
{ {
// get the library with the specified id from the repository
ILibraryRepository libraryRepository = _unitOfWork.GetRepository<ILibraryRepository>(); ILibraryRepository libraryRepository = _unitOfWork.GetRepository<ILibraryRepository>();
ErrorOr<LibraryEntity?> getLibraryResult = await libraryRepository.GetByIdAsync(request.Id, cancellationToken).ConfigureAwait(false); ErrorOr<LibraryEntity?> getLibraryResult = await libraryRepository.GetByIdAsync(request.Id, cancellationToken).ConfigureAwait(false);
if (getLibraryResult.IsError) if (getLibraryResult.IsError)
return getLibraryResult.Errors; return getLibraryResult.Errors;
else if (getLibraryResult.Value is null) else if (getLibraryResult.Value is null)
return DomainErrors.Library.LibraryNotFound; return DomainErrors.Library.LibraryNotFound;
// if the user that requested the library is not an Admin or is not the owner of the library, they do not have the right to view it // if the user that requested the library is not an Admin or is not the owner of the library, they do not have the right to view it
if (getLibraryResult.Value.UserId != request.UserId) // 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).ConfigureAwait(false) &&
!await _authorizationService.HasPermissionAsync(_currentUserService.UserId!.Value, AuthorizationPermission.CanCreateLibraries, cancellationToken)))
return ApplicationErrors.Authorization.NotAuthorized; return ApplicationErrors.Authorization.NotAuthorized;
return getLibraryResult.Value.ToResponse(); return getLibraryResult.Value.ToResponse();
} }
} }
@@ -4,7 +4,7 @@ using Lumina.Domain.Common.Errors;
using System; using System;
#endregion #endregion
namespace Lumina.Application.Core.MediaLibrary.Management.Queries; namespace Lumina.Application.Core.MediaLibrary.Management.Queries.GetLibrary;
/// <summary> /// <summary>
/// Validates the needed validation rules for <see cref="GetLibraryQuery"/>. /// Validates the needed validation rules for <see cref="GetLibraryQuery"/>.
@@ -19,9 +19,5 @@ public class GetLibraryQueryValidator : AbstractValidator<GetLibraryQuery>
RuleFor(x => x.Id) RuleFor(x => x.Id)
.NotEmpty().WithMessage(Errors.Library.LibraryIdCannotBeEmpty.Description) .NotEmpty().WithMessage(Errors.Library.LibraryIdCannotBeEmpty.Description)
.Must(id => id != Guid.Empty).WithMessage(Errors.Library.LibraryIdCannotBeEmpty.Description); .Must(id => id != Guid.Empty).WithMessage(Errors.Library.LibraryIdCannotBeEmpty.Description);
RuleFor(x => x.UserId)
.NotEmpty().WithMessage(Errors.Users.UserIdCannotBeEmpty.Description)
.Must(id => id != Guid.Empty).WithMessage(Errors.Users.UserIdCannotBeEmpty.Description);
} }
} }
@@ -45,7 +45,7 @@ public class AddBookCommandHandler : IRequestHandler<AddBookCommand, ErrorOr<Boo
/// <param name="request">The request to be handled.</param> /// <param name="request">The request to be handled.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param> /// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns> /// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="BookResponse"/>, or an error message. /// An <see cref="ErrorOr{TValue}"/> containing either a successfuly created <see cref="BookResponse"/>, or an error message.
/// </returns> /// </returns>
public async ValueTask<ErrorOr<BookResponse>> Handle(AddBookCommand request, CancellationToken cancellationToken) public async ValueTask<ErrorOr<BookResponse>> Handle(AddBookCommand request, CancellationToken cancellationToken)
{ {
@@ -41,7 +41,7 @@ public class ChangePasswordCommandHandler : IRequestHandler<ChangePasswordComman
/// <param name="request">The request to be handled.</param> /// <param name="request">The request to be handled.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param> /// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns> /// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="ChangePasswordResponse"/>, or an error message. /// An <see cref="ErrorOr{TValue}"/> containing either a successfuly created <see cref="ChangePasswordResponse"/>, or an error message.
/// </returns> /// </returns>
public async ValueTask<ErrorOr<ChangePasswordResponse>> Handle(ChangePasswordCommand request, CancellationToken cancellationToken) public async ValueTask<ErrorOr<ChangePasswordResponse>> Handle(ChangePasswordCommand request, CancellationToken cancellationToken)
{ {
@@ -50,7 +50,7 @@ public class RecoverPasswordCommandHandler : IRequestHandler<RecoverPasswordComm
/// <param name="request">The request to be handled.</param> /// <param name="request">The request to be handled.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param> /// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns> /// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="RecoverPasswordResponse"/>, or an error message. /// An <see cref="ErrorOr{TValue}"/> containing either a successfuly created <see cref="RecoverPasswordResponse"/>, or an error message.
/// </returns> /// </returns>
public async ValueTask<ErrorOr<RecoverPasswordResponse>> Handle(RecoverPasswordCommand request, CancellationToken cancellationToken) public async ValueTask<ErrorOr<RecoverPasswordResponse>> Handle(RecoverPasswordCommand request, CancellationToken cancellationToken)
{ {
@@ -59,7 +59,7 @@ public class RegisterUserCommandHandler : IRequestHandler<RegisterUserCommand, E
/// <param name="request">The request to be handled.</param> /// <param name="request">The request to be handled.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param> /// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns> /// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="RegistrationResponse"/>, or an error message. /// An <see cref="ErrorOr{TValue}"/> containing either a successfuly created <see cref="RegistrationResponse"/>, or an error message.
/// </returns> /// </returns>
public async ValueTask<ErrorOr<RegistrationResponse>> Handle(RegisterUserCommand request, CancellationToken cancellationToken) public async ValueTask<ErrorOr<RegistrationResponse>> Handle(RegisterUserCommand request, CancellationToken cancellationToken)
{ {
@@ -59,7 +59,7 @@ public class LoginUserQueryHandler : IRequestHandler<LoginUserQuery, ErrorOr<Log
/// <param name="request">The request to be handled.</param> /// <param name="request">The request to be handled.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param> /// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns> /// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="LoginResponse"/>, or an error message. /// An <see cref="ErrorOr{TValue}"/> containing either a successfuly created <see cref="LoginResponse"/>, or an error message.
/// </returns> /// </returns>
public async ValueTask<ErrorOr<LoginResponse>> Handle(LoginUserQuery request, CancellationToken cancellationToken) public async ValueTask<ErrorOr<LoginResponse>> Handle(LoginUserQuery request, CancellationToken cancellationToken)
{ {
@@ -48,7 +48,7 @@ public class UpdateUserRoleAndPermissionsCommandHandler : IRequestHandler<Update
/// <param name="request">The request to be handled.</param> /// <param name="request">The request to be handled.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param> /// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns> /// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully updated <see cref="RoleResponse"/>, or an error message. /// An <see cref="ErrorOr{TValue}"/> containing either a successfuly updated <see cref="RoleResponse"/>, or an error message.
/// </returns> /// </returns>
public async ValueTask<ErrorOr<AuthorizationResponse>> Handle(UpdateUserRoleAndPermissionsCommand request, CancellationToken cancellationToken) public async ValueTask<ErrorOr<AuthorizationResponse>> Handle(UpdateUserRoleAndPermissionsCommand request, CancellationToken cancellationToken)
{ {
@@ -0,0 +1,15 @@
#region ========================================================================= USING =====================================================================================
using System;
using System.Diagnostics;
#endregion
namespace Lumina.Contracts.Requests.MediaLibrary.Management;
/// <summary>
/// Represents a request to delete a media library by its Id.
/// </summary>
/// <param name="Id">The Id of the media library. Required.</param>
[DebuggerDisplay("Id: {Id}")]
public record DeleteLibraryRequest(
Guid Id
);
@@ -35,7 +35,7 @@ internal sealed class PermissionRepository : IPermissionRepository
/// </summary> /// </summary>
/// <param name="permission">The authorization permission to add.</param> /// <param name="permission">The authorization permission to add.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param> /// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successfull operation, or an error.</returns> /// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successful operation, or an error.</returns>
public async Task<ErrorOr<Created>> InsertAsync(PermissionEntity permission, CancellationToken cancellationToken) public async Task<ErrorOr<Created>> InsertAsync(PermissionEntity permission, CancellationToken cancellationToken)
{ {
bool permissionExists = await _luminaDbContext.Permissions.AnyAsync(repositoryPermission => repositoryPermission.Id == permission.Id, cancellationToken).ConfigureAwait(false); bool permissionExists = await _luminaDbContext.Permissions.AnyAsync(repositoryPermission => repositoryPermission.Id == permission.Id, cancellationToken).ConfigureAwait(false);
@@ -30,7 +30,7 @@ internal sealed class RolePermissionRepository : IRolePermissionRepository
/// </summary> /// </summary>
/// <param name="rolePermission">The authorization role permission to add.</param> /// <param name="rolePermission">The authorization role permission to add.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param> /// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successfull operation, or an error.</returns> /// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successful operation, or an error.</returns>
public async Task<ErrorOr<Created>> InsertAsync(RolePermissionEntity rolePermission, CancellationToken cancellationToken) public async Task<ErrorOr<Created>> InsertAsync(RolePermissionEntity rolePermission, CancellationToken cancellationToken)
{ {
_luminaDbContext.RolePermissions.Add(rolePermission); _luminaDbContext.RolePermissions.Add(rolePermission);
@@ -34,7 +34,7 @@ internal sealed class RoleRepository : IRoleRepository
/// </summary> /// </summary>
/// <param name="role">The authorization role to add.</param> /// <param name="role">The authorization role to add.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param> /// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successfull operation, or an error.</returns> /// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successful operation, or an error.</returns>
public async Task<ErrorOr<Created>> InsertAsync(RoleEntity role, CancellationToken cancellationToken) public async Task<ErrorOr<Created>> InsertAsync(RoleEntity role, CancellationToken cancellationToken)
{ {
bool roleExists = await _luminaDbContext.Roles.AnyAsync(repositoryRole => repositoryRole.Id == role.Id || repositoryRole.RoleName == role.RoleName, cancellationToken).ConfigureAwait(false); bool roleExists = await _luminaDbContext.Roles.AnyAsync(repositoryRole => repositoryRole.Id == role.Id || repositoryRole.RoleName == role.RoleName, cancellationToken).ConfigureAwait(false);
@@ -90,7 +90,7 @@ internal sealed class RoleRepository : IRoleRepository
/// </summary> /// </summary>
/// <param name="data">The role to update.</param> /// <param name="data">The role to update.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param> /// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successfull operation, or an error.</returns> /// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successful operation, or an error.</returns>
public async Task<ErrorOr<Updated>> UpdateAsync(RoleEntity data, CancellationToken cancellationToken) public async Task<ErrorOr<Updated>> UpdateAsync(RoleEntity data, CancellationToken cancellationToken)
{ {
// check if a role with the requested Id exists, and retrieve it // check if a role with the requested Id exists, and retrieve it
@@ -114,7 +114,7 @@ internal sealed class RoleRepository : IRoleRepository
/// </summary> /// </summary>
/// <param name="id">The id of the role to be deleted.</param> /// <param name="id">The id of the role to be deleted.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param> /// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successfull operation, or an error.</returns> /// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successful operation, or an error.</returns>
public async Task<ErrorOr<Deleted>> DeleteByIdAsync(Guid id, CancellationToken cancellationToken) public async Task<ErrorOr<Deleted>> DeleteByIdAsync(Guid id, CancellationToken cancellationToken)
{ {
// check if a role with the requested Id exists, and retrieve it // check if a role with the requested Id exists, and retrieve it
@@ -30,7 +30,7 @@ internal sealed class UserRoleRepository : IUserRoleRepository
/// </summary> /// </summary>
/// <param name="userRole">The authorization user role to add.</param> /// <param name="userRole">The authorization user role to add.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param> /// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successfull operation, or an error.</returns> /// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successful operation, or an error.</returns>
public async Task<ErrorOr<Created>> InsertAsync(UserRoleEntity userRole, CancellationToken cancellationToken) public async Task<ErrorOr<Created>> InsertAsync(UserRoleEntity userRole, CancellationToken cancellationToken)
{ {
_luminaDbContext.UserRoles.Add(userRole); _luminaDbContext.UserRoles.Add(userRole);
@@ -35,7 +35,7 @@ internal sealed class BookRepository : IBookRepository
/// </summary> /// </summary>
/// <param name="book">The book to add.</param> /// <param name="book">The book to add.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param> /// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successfull operation, or an error.</returns> /// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successful operation, or an error.</returns>
public async Task<ErrorOr<Created>> InsertAsync(BookEntity book, CancellationToken cancellationToken) public async Task<ErrorOr<Created>> InsertAsync(BookEntity book, CancellationToken cancellationToken)
{ {
bool bookExists = await _luminaDbContext.Books.AnyAsync(repositoryBook => repositoryBook.Id == book.Id, cancellationToken: cancellationToken).ConfigureAwait(false); bool bookExists = await _luminaDbContext.Books.AnyAsync(repositoryBook => repositoryBook.Id == book.Id, cancellationToken: cancellationToken).ConfigureAwait(false);
@@ -6,6 +6,7 @@ using Lumina.DataAccess.Core.UoW;
using Lumina.Domain.Common.Errors; using Lumina.Domain.Common.Errors;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using System; using System;
using System.Collections.Generic;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
#endregion #endregion
@@ -33,7 +34,7 @@ internal sealed class LibraryRepository : ILibraryRepository
/// </summary> /// </summary>
/// <param name="library">The library to add.</param> /// <param name="library">The library to add.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param> /// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successfull operation, or an error.</returns> /// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successful operation, or an error.</returns>
public async Task<ErrorOr<Created>> InsertAsync(LibraryEntity library, CancellationToken cancellationToken) public async Task<ErrorOr<Created>> InsertAsync(LibraryEntity library, CancellationToken cancellationToken)
{ {
bool libraryExists = await _luminaDbContext.Libraries.AnyAsync(repositoryLibrary => repositoryLibrary.Id == library.Id, cancellationToken: cancellationToken).ConfigureAwait(false); bool libraryExists = await _luminaDbContext.Libraries.AnyAsync(repositoryLibrary => repositoryLibrary.Id == library.Id, cancellationToken: cancellationToken).ConfigureAwait(false);
@@ -57,12 +58,24 @@ internal sealed class LibraryRepository : ILibraryRepository
.FirstOrDefaultAsync(library => library.Id == id, cancellationToken).ConfigureAwait(false); .FirstOrDefaultAsync(library => library.Id == id, cancellationToken).ConfigureAwait(false);
} }
/// <summary>
/// Gets all media libraries.
/// </summary>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="ErrorOr{TValue}"/> containing either a collection of <see cref="LibraryEntity"/>, or an error.</returns>
public async Task<ErrorOr<IEnumerable<LibraryEntity>>> GetAllAsync(CancellationToken cancellationToken)
{
return await _luminaDbContext.Libraries
.Include(library => library.ContentLocations)
.ToListAsync(cancellationToken).ConfigureAwait(false);
}
/// <summary> /// <summary>
/// Updates a media library. /// Updates a media library.
/// </summary> /// </summary>
/// <param name="data">The media library to update.</param> /// <param name="data">The media library to update.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param> /// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successfull operation, or an error.</returns> /// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successful operation, or an error.</returns>
public async Task<ErrorOr<Updated>> UpdateAsync(LibraryEntity data, CancellationToken cancellationToken) public async Task<ErrorOr<Updated>> UpdateAsync(LibraryEntity data, CancellationToken cancellationToken)
{ {
LibraryEntity? foundLibrary = await _luminaDbContext.Libraries LibraryEntity? foundLibrary = await _luminaDbContext.Libraries
@@ -78,4 +91,24 @@ internal sealed class LibraryRepository : ILibraryRepository
foundLibrary.ContentLocations.Add(contentLocation); foundLibrary.ContentLocations.Add(contentLocation);
return Result.Updated; return Result.Updated;
} }
/// <summary>
/// Deletes a library by its ID.
/// </summary>
/// <param name="id">The ID of the library to delete.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successful operation, or an error.</returns>
public async Task<ErrorOr<Deleted>> DeleteByIdAsync(Guid id, CancellationToken cancellationToken)
{
LibraryEntity? library = await _luminaDbContext.Libraries
.Include(library => library.ContentLocations)
.FirstOrDefaultAsync(library => library.Id == id, cancellationToken)
.ConfigureAwait(false);
if (library is null)
return Errors.Library.LibraryNotFound;
_luminaDbContext.Libraries.Remove(library);
return Result.Deleted;
}
} }
@@ -35,7 +35,7 @@ internal sealed class UserRepository : IUserRepository
/// </summary> /// </summary>
/// <param name="user">The user to add.</param> /// <param name="user">The user to add.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param> /// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successfull operation, or an error.</returns> /// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successful operation, or an error.</returns>
public async Task<ErrorOr<Created>> InsertAsync(UserEntity user, CancellationToken cancellationToken) public async Task<ErrorOr<Created>> InsertAsync(UserEntity user, CancellationToken cancellationToken)
{ {
bool userExists = await _luminaDbContext.Users.AnyAsync(repositoryUser => repositoryUser.Id == user.Id, cancellationToken: cancellationToken).ConfigureAwait(false); bool userExists = await _luminaDbContext.Users.AnyAsync(repositoryUser => repositoryUser.Id == user.Id, cancellationToken: cancellationToken).ConfigureAwait(false);
@@ -80,7 +80,7 @@ internal sealed class UserRepository : IUserRepository
/// </summary> /// </summary>
/// <param name="data">Ther user to update.</param> /// <param name="data">Ther user to update.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param> /// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successfull operation, or an error.</returns> /// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successful operation, or an error.</returns>
public async Task<ErrorOr<Updated>> UpdateAsync(UserEntity data, CancellationToken cancellationToken) public async Task<ErrorOr<Updated>> UpdateAsync(UserEntity data, CancellationToken cancellationToken)
{ {
UserEntity? foundUser = await _luminaDbContext.Users UserEntity? foundUser = await _luminaDbContext.Users
@@ -41,7 +41,7 @@ public class DataSeedService : IDataSeedService
/// </summary> /// </summary>
/// <param name="adminId">The Id of the admin admin user who will own these permissions.</param> /// <param name="adminId">The Id of the admin admin user who will own these permissions.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param> /// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successfull operation, or an error.</returns> /// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successful operation, or an error.</returns>
public async Task<ErrorOr<Created>> SetDefaultAuthorizationPermissionsAsync(Guid adminId, CancellationToken cancellationToken) public async Task<ErrorOr<Created>> SetDefaultAuthorizationPermissionsAsync(Guid adminId, CancellationToken cancellationToken)
{ {
IPermissionRepository permissionRepository = _unitOfWork.GetRepository<IPermissionRepository>(); IPermissionRepository permissionRepository = _unitOfWork.GetRepository<IPermissionRepository>();
@@ -51,7 +51,7 @@ public class DataSeedService : IDataSeedService
new() { PermissionName = AuthorizationPermission.CanViewUsers, CreatedBy = adminId, CreatedOnUtc = _dateTimeProvider.UtcNow }, new() { PermissionName = AuthorizationPermission.CanViewUsers, CreatedBy = adminId, CreatedOnUtc = _dateTimeProvider.UtcNow },
new() { PermissionName = AuthorizationPermission.CanDeleteUsers, CreatedBy = adminId, CreatedOnUtc = _dateTimeProvider.UtcNow }, new() { PermissionName = AuthorizationPermission.CanDeleteUsers, CreatedBy = adminId, CreatedOnUtc = _dateTimeProvider.UtcNow },
new() { PermissionName = AuthorizationPermission.CanRegisterUsers, CreatedBy = adminId, CreatedOnUtc = _dateTimeProvider.UtcNow }, new() { PermissionName = AuthorizationPermission.CanRegisterUsers, CreatedBy = adminId, CreatedOnUtc = _dateTimeProvider.UtcNow },
new() { PermissionName = AuthorizationPermission.canCreateLibraries, CreatedBy = adminId, CreatedOnUtc = _dateTimeProvider.UtcNow } new() { PermissionName = AuthorizationPermission.CanCreateLibraries, CreatedBy = adminId, CreatedOnUtc = _dateTimeProvider.UtcNow }
]; ];
foreach (PermissionEntity permission in defaultPermissions) foreach (PermissionEntity permission in defaultPermissions)
{ {
@@ -68,7 +68,7 @@ public class DataSeedService : IDataSeedService
/// </summary> /// </summary>
/// <param name="userId">The Id of the admin user for whom roles will be set.</param> /// <param name="userId">The Id of the admin user for whom roles will be set.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param> /// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successfull operation, or an error.</returns> /// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successful operation, or an error.</returns>
public async Task<ErrorOr<Created>> SetDefaultAuthorizationRolesAsync(Guid userId, CancellationToken cancellationToken) public async Task<ErrorOr<Created>> SetDefaultAuthorizationRolesAsync(Guid userId, CancellationToken cancellationToken)
{ {
IRoleRepository roleRepository = _unitOfWork.GetRepository<IRoleRepository>(); IRoleRepository roleRepository = _unitOfWork.GetRepository<IRoleRepository>();
@@ -93,7 +93,7 @@ public class DataSeedService : IDataSeedService
/// </summary> /// </summary>
/// <param name="userId">The Id of the admin user to receive admin role permissions.</param> /// <param name="userId">The Id of the admin user to receive admin role permissions.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param> /// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successfull operation, or an error.</returns> /// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successful operation, or an error.</returns>
public async Task<ErrorOr<Created>> SetAdminRolePermissionsAsync(Guid userId, CancellationToken cancellationToken) public async Task<ErrorOr<Created>> SetAdminRolePermissionsAsync(Guid userId, CancellationToken cancellationToken)
{ {
IRolePermissionRepository rolePermissionRepository = _unitOfWork.GetRepository<IRolePermissionRepository>(); IRolePermissionRepository rolePermissionRepository = _unitOfWork.GetRepository<IRolePermissionRepository>();
@@ -138,7 +138,7 @@ public class DataSeedService : IDataSeedService
/// </summary> /// </summary>
/// <param name="userId">The Id of the admin user to receive the admin role.</param> /// <param name="userId">The Id of the admin user to receive the admin role.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param> /// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successfull operation, or an error.</returns> /// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successful operation, or an error.</returns>
public async Task<ErrorOr<Created>> SetAdminRoleToAdministratorAccount(Guid userId, CancellationToken cancellationToken) public async Task<ErrorOr<Created>> SetAdminRoleToAdministratorAccount(Guid userId, CancellationToken cancellationToken)
{ {
IUserRoleRepository userRoleRepository = _unitOfWork.GetRepository<IUserRoleRepository>(); IUserRoleRepository userRoleRepository = _unitOfWork.GetRepository<IUserRoleRepository>();
@@ -9,5 +9,5 @@ public enum AuthorizationPermission
CanViewUsers, CanViewUsers,
CanDeleteUsers, CanDeleteUsers,
CanRegisterUsers, CanRegisterUsers,
canCreateLibraries CanCreateLibraries
} }
@@ -32,7 +32,7 @@ public class Genre : ValueObject
/// </summary> /// </summary>
/// <param name="name">The value of the genre.</param> /// <param name="name">The value of the genre.</param>
/// <returns> /// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="Genre"/>, or an error message. /// An <see cref="ErrorOr{TValue}"/> containing either a successfuly created <see cref="Genre"/>, or an error message.
/// </returns> /// </returns>
public static ErrorOr<Genre> Create(string? name) public static ErrorOr<Genre> Create(string? name)
{ {
@@ -49,7 +49,7 @@ public class LanguageInfo : ValueObject
/// <param name="languageName">The full name of the language in English.</param> /// <param name="languageName">The full name of the language in English.</param>
/// <param name="nativeName">The optional native name of the language.</param> /// <param name="nativeName">The optional native name of the language.</param>
/// <returns> /// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="LanguageInfo"/>, or an error message. /// An <see cref="ErrorOr{TValue}"/> containing either a successfuly created <see cref="LanguageInfo"/>, or an error message.
/// </returns> /// </returns>
public static ErrorOr<LanguageInfo> Create(string? languageCode, string? languageName, Optional<string> nativeName) public static ErrorOr<LanguageInfo> Create(string? languageCode, string? languageName, Optional<string> nativeName)
{ {
@@ -81,7 +81,7 @@ public class ReleaseInfo : ValueObject
/// <param name="releaseCountry">The optional country or region of release.</param> /// <param name="releaseCountry">The optional country or region of release.</param>
/// <param name="releaseVersion">The optional release version or edition.</param> /// <param name="releaseVersion">The optional release version or edition.</param>
/// <returns> /// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="ReleaseInfo"/>, or an error message. /// An <see cref="ErrorOr{TValue}"/> containing either a successfuly created <see cref="ReleaseInfo"/>, or an error message.
/// </returns> /// </returns>
public static ErrorOr<ReleaseInfo> Create( public static ErrorOr<ReleaseInfo> Create(
Optional<DateOnly> originalReleaseDate, Optional<DateOnly> originalReleaseDate,
@@ -32,7 +32,7 @@ public class Tag : ValueObject
/// </summary> /// </summary>
/// <param name="name">The value of the tag.</param> /// <param name="name">The value of the tag.</param>
/// <returns> /// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="Tag"/>, or an error message. /// An <see cref="ErrorOr{TValue}"/> containing either a successfuly created <see cref="Tag"/>, or an error message.
/// </returns> /// </returns>
public static ErrorOr<Tag> Create(string? name) public static ErrorOr<Tag> Create(string? name)
{ {
@@ -102,7 +102,7 @@ public class AudioMetadata : BaseMetadata
/// <param name="genres">The genres of the audio.</param> /// <param name="genres">The genres of the audio.</param>
/// <param name="tags">The tags associated with the audio.</param> /// <param name="tags">The tags associated with the audio.</param>
/// <returns> /// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="AudioMetadata"/>, or an error message. /// An <see cref="ErrorOr{TValue}"/> containing either a successfuly created <see cref="AudioMetadata"/>, or an error message.
/// </returns> /// </returns>
public static ErrorOr<AudioMetadata> Create( public static ErrorOr<AudioMetadata> Create(
string title, string title,
@@ -55,7 +55,7 @@ public sealed class Directory : FileSystemItem
/// <param name="dateModified">The date and time the directory was last modified. Can be optional if unknown.</param> /// <param name="dateModified">The date and time the directory was last modified. Can be optional if unknown.</param>
/// <param name="status">The status of the file system item.</param> /// <param name="status">The status of the file system item.</param>
/// <returns> /// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="Directory"/>, or an error message. /// An <see cref="ErrorOr{TValue}"/> containing either a successfuly created <see cref="Directory"/>, or an error message.
/// </returns> /// </returns>
public static ErrorOr<Directory> Create( public static ErrorOr<Directory> Create(
string path, string path,
@@ -87,7 +87,7 @@ public sealed class Directory : FileSystemItem
/// <param name="dateModified">The date and time the directory was last modified. Can be optional if unknown.</param> /// <param name="dateModified">The date and time the directory was last modified. Can be optional if unknown.</param>
/// <param name="status">The status of the file system item.</param> /// <param name="status">The status of the file system item.</param>
/// <returns> /// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="Directory"/>, or an error message. /// An <see cref="ErrorOr{TValue}"/> containing either a successfuly created <see cref="Directory"/>, or an error message.
/// </returns> /// </returns>
public static ErrorOr<Directory> Create( public static ErrorOr<Directory> Create(
FileSystemPathId id, FileSystemPathId id,
@@ -112,7 +112,7 @@ public sealed class Directory : FileSystemItem
/// Updates the last modified date of the file system item. /// Updates the last modified date of the file system item.
/// </summary> /// </summary>
/// <param name="date">The new date and time of last modification.</param> /// <param name="date">The new date and time of last modification.</param>
/// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successfull operation, or an error.</returns> /// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successful operation, or an error.</returns>
public ErrorOr<Updated> UpdateLastModified(DateTime date) public ErrorOr<Updated> UpdateLastModified(DateTime date)
{ {
DateModified = date; DateModified = date;
@@ -123,7 +123,7 @@ public sealed class Directory : FileSystemItem
/// Adds a file system item to the directory. /// Adds a file system item to the directory.
/// </summary> /// </summary>
/// <param name="item">The file system item to add.</param> /// <param name="item">The file system item to add.</param>
/// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successfull operation, or an error.</returns> /// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successful operation, or an error.</returns>
public ErrorOr<Updated> AddItem(FileSystemItem item) public ErrorOr<Updated> AddItem(FileSystemItem item)
{ {
_items.Add(item); _items.Add(item);
@@ -134,7 +134,7 @@ public sealed class Directory : FileSystemItem
/// Removes a file system item from the directory. /// Removes a file system item from the directory.
/// </summary> /// </summary>
/// <param name="item">The file system item to remove.</param> /// <param name="item">The file system item to remove.</param>
/// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successfull operation, or an error.</returns> /// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successful operation, or an error.</returns>
public ErrorOr<Updated> RemoveItem(FileSystemItem item) public ErrorOr<Updated> RemoveItem(FileSystemItem item)
{ {
_items.Remove(item); _items.Remove(item);
@@ -56,7 +56,7 @@ public sealed class File : FileSystemItem
/// <param name="size">The size of the file in bytes.</param> /// <param name="size">The size of the file in bytes.</param>
/// <param name="status">The status of the file system item.</param> /// <param name="status">The status of the file system item.</param>
/// <returns> /// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="File"/>, or an error message. /// An <see cref="ErrorOr{TValue}"/> containing either a successfuly created <see cref="File"/>, or an error message.
/// </returns> /// </returns>
public static ErrorOr<File> Create( public static ErrorOr<File> Create(
string path, string path,
@@ -92,7 +92,7 @@ public sealed class File : FileSystemItem
/// <param name="size">The size of the file in bytes.</param> /// <param name="size">The size of the file in bytes.</param>
/// <param name="status">The status of the file system item.</param> /// <param name="status">The status of the file system item.</param>
/// <returns> /// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="File"/>, or an error message. /// An <see cref="ErrorOr{TValue}"/> containing either a successfuly created <see cref="File"/>, or an error message.
/// </returns> /// </returns>
public static ErrorOr<File> Create( public static ErrorOr<File> Create(
FileSystemPathId id, FileSystemPathId id,
@@ -119,7 +119,7 @@ public sealed class File : FileSystemItem
/// Updates the last modified date of the file system item. /// Updates the last modified date of the file system item.
/// </summary> /// </summary>
/// <param name="date">The new date and time of last modification.</param> /// <param name="date">The new date and time of last modification.</param>
/// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successfull operation, or an error.</returns> /// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successful operation, or an error.</returns>
public ErrorOr<Updated> UpdateLastModified(DateTime date) public ErrorOr<Updated> UpdateLastModified(DateTime date)
{ {
DateModified = date; DateModified = date;
@@ -130,7 +130,7 @@ public sealed class File : FileSystemItem
/// Updates the size of the file. /// Updates the size of the file.
/// </summary> /// </summary>
/// <param name="newSize">The new size, in bytes.</param> /// <param name="newSize">The new size, in bytes.</param>
/// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successfull operation, or an error.</returns> /// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successful operation, or an error.</returns>
public ErrorOr<Updated> UpdateSize(long newSize) public ErrorOr<Updated> UpdateSize(long newSize)
{ {
Size = newSize; Size = newSize;
@@ -141,7 +141,7 @@ public sealed class File : FileSystemItem
/// Renames the file system item to the specified new name. /// Renames the file system item to the specified new name.
/// </summary> /// </summary>
/// <param name="newName">The new name for the file system item.</param> /// <param name="newName">The new name for the file system item.</param>
/// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successfull operation, or an error.</returns> /// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successful operation, or an error.</returns>
public ErrorOr<Updated> Rename(string newName) public ErrorOr<Updated> Rename(string newName)
{ {
if (string.IsNullOrWhiteSpace(newName)) if (string.IsNullOrWhiteSpace(newName))
@@ -37,7 +37,7 @@ public sealed class UnixRootItem : FileSystemItem
/// </summary> /// </summary>
/// <param name="status">The status of the file system root item.</param> /// <param name="status">The status of the file system root item.</param>
/// <returns> /// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="UnixRootItem"/>, or an error message. /// An <see cref="ErrorOr{TValue}"/> containing either a successfuly created <see cref="UnixRootItem"/>, or an error message.
/// </returns> /// </returns>
public static ErrorOr<UnixRootItem> Create(FileSystemItemStatus status = FileSystemItemStatus.Accessible) public static ErrorOr<UnixRootItem> Create(FileSystemItemStatus status = FileSystemItemStatus.Accessible)
{ {
@@ -38,7 +38,7 @@ public sealed class WindowsRootItem : FileSystemItem
/// <param name="name">The name of the file system root item.</param> /// <param name="name">The name of the file system root item.</param>
/// <param name="status">The status of the file system root item.</param> /// <param name="status">The status of the file system root item.</param>
/// <returns> /// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="WindowsRootItem"/>, or an error message. /// An <see cref="ErrorOr{TValue}"/> containing either a successfuly created <see cref="WindowsRootItem"/>, or an error message.
/// </returns> /// </returns>
public static ErrorOr<WindowsRootItem> Create( public static ErrorOr<WindowsRootItem> Create(
string path, string path,
@@ -65,7 +65,7 @@ public sealed class WindowsRootItem : FileSystemItem
/// <param name="name">The name of the file system root item.</param> /// <param name="name">The name of the file system root item.</param>
/// <param name="status">The status of the file system root item.</param> /// <param name="status">The status of the file system root item.</param>
/// <returns> /// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="WindowsRootItem"/>, or an error message. /// An <see cref="ErrorOr{TValue}"/> containing either a successfuly created <see cref="WindowsRootItem"/>, or an error message.
/// </returns> /// </returns>
public static ErrorOr<WindowsRootItem> Create( public static ErrorOr<WindowsRootItem> Create(
FileSystemPathId id, FileSystemPathId id,
@@ -52,7 +52,7 @@ public abstract class FileSystemItem : AggregateRoot<FileSystemPathId>
/// Sets the status of the filesystem item. /// Sets the status of the filesystem item.
/// </summary> /// </summary>
/// <param name="status">The status to be set.</param> /// <param name="status">The status to be set.</param>
/// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successfull operation, or an error.</returns> /// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successful operation, or an error.</returns>
public ErrorOr<Updated> SetStatus(FileSystemItemStatus status) public ErrorOr<Updated> SetStatus(FileSystemItemStatus status)
{ {
Status = status; Status = status;
@@ -63,7 +63,7 @@ public abstract class FileSystemItem : AggregateRoot<FileSystemPathId>
/// Sets the parent of the filesystem item. /// Sets the parent of the filesystem item.
/// </summary> /// </summary>
/// <param name="parent">The file system item to be set as parent.</param> /// <param name="parent">The file system item to be set as parent.</param>
/// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successfull operation, or an error.</returns> /// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successful operation, or an error.</returns>
public ErrorOr<Updated> SetParent(FileSystemItem parent) public ErrorOr<Updated> SetParent(FileSystemItem parent)
{ {
if (parent is not null) if (parent is not null)
@@ -30,7 +30,7 @@ internal class FileSystemStructureSeedService : IFileSystemStructureSeedService
/// Sets up the default file system directories needed by the application. /// Sets up the default file system directories needed by the application.
/// </summary> /// </summary>
/// <param name="rootPath">The base path where the directories will be created relative to.</param> /// <param name="rootPath">The base path where the directories will be created relative to.</param>
/// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successfull operation, or an error.</returns> /// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successful operation, or an error.</returns>
public ErrorOr<Created> SetDefaultDirectories(string rootPath) public ErrorOr<Created> SetDefaultDirectories(string rootPath)
{ {
// make sure the root path exists // make sure the root path exists
@@ -13,6 +13,6 @@ public interface IFileSystemStructureSeedService
/// Sets up the default file system directories needed by the application. /// Sets up the default file system directories needed by the application.
/// </summary> /// </summary>
/// <param name="rootPath">The base path where the directories will be created relative to.</param> /// <param name="rootPath">The base path where the directories will be created relative to.</param>
/// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successfull operation, or an error.</returns> /// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successful operation, or an error.</returns>
ErrorOr<Created> SetDefaultDirectories(string rootPath); ErrorOr<Created> SetDefaultDirectories(string rootPath);
} }
@@ -39,7 +39,7 @@ public sealed class FileSystemPathId : ValueObject
/// </summary> /// </summary>
/// <param name="path">The path of the file system item.</param> /// <param name="path">The path of the file system item.</param>
/// <returns> /// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="FileSystemPathId"/> or an error message. /// An <see cref="ErrorOr{TValue}"/> containing either a successfuly created <see cref="FileSystemPathId"/> or an error message.
/// </returns> /// </returns>
public static ErrorOr<FileSystemPathId> Create(string path) public static ErrorOr<FileSystemPathId> Create(string path)
{ {
@@ -49,7 +49,7 @@ public class PathSegment : ValueObject
/// <param name="isDirectory">Value indicating if the current path segment is a file system directory or not.</param> /// <param name="isDirectory">Value indicating if the current path segment is a file system directory or not.</param>
/// <param name="isDrive">Value indicating if the current path segment is a file system drive or not.</param> /// <param name="isDrive">Value indicating if the current path segment is a file system drive or not.</param>
/// <returns> /// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="PathSegment"/> or an error message. /// An <see cref="ErrorOr{TValue}"/> containing either a successfuly created <see cref="PathSegment"/> or an error message.
/// </returns> /// </returns>
public static ErrorOr<PathSegment> Create(string name, bool isDirectory, bool isDrive) public static ErrorOr<PathSegment> Create(string name, bool isDirectory, bool isDrive)
{ {
@@ -98,7 +98,7 @@ public class StreamInfo : ValueObject
/// <param name="sampleRate">The sample rate of the stream (for audio).</param> /// <param name="sampleRate">The sample rate of the stream (for audio).</param>
/// <param name="channels">The number of channels (for audio).</param> /// <param name="channels">The number of channels (for audio).</param>
/// <returns> /// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="StreamInfo"/>, or an error message. /// An <see cref="ErrorOr{TValue}"/> containing either a successfuly created <see cref="StreamInfo"/>, or an error message.
/// </returns> /// </returns>
public static ErrorOr<StreamInfo> Create( public static ErrorOr<StreamInfo> Create(
string streamId, string streamId,
@@ -0,0 +1,20 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Common.Events;
using System;
using System.Diagnostics;
#endregion
namespace Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.Events;
/// <summary>
/// Domain event raised when a libary is deleted.
/// </summary>
/// <param name="Id">The Id of the domain event.</param>
/// <param name="Library">The library that was deleted.</param>
/// <param name="OccurredOnUtc">The date and time when the domain event occurred.</param>
[DebuggerDisplay("Id: {Library.Id} Title: {Library.Title}")]
public record LibraryDeletedDomainEvent(
Guid Id,
Library Library,
DateTime OccurredOnUtc
) : IDomainEvent;
@@ -9,6 +9,7 @@ using Lumina.Domain.Core.BoundedContexts.UserManagementBoundedContext.UserAggreg
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Linq;
#endregion #endregion
namespace Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate; namespace Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate;
@@ -86,7 +87,7 @@ public class Library : AggregateRoot<LibraryId>
/// <param name="contentLocations">The list of file system paths that make up the media library.</param> /// <param name="contentLocations">The list of file system paths that make up the media library.</param>
/// <param name="coverImageSourcePath">The path of the image file chosen by the user to be used as the cover for the library.</param> /// <param name="coverImageSourcePath">The path of the image file chosen by the user to be used as the cover for the library.</param>
/// <returns> /// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="Library"/>, or an error message. /// An <see cref="ErrorOr{TValue}"/> containing either a successfuly created <see cref="Library"/>, or an error message.
/// </returns> /// </returns>
public static ErrorOr<Library> Create( public static ErrorOr<Library> Create(
Guid userId, Guid userId,
@@ -124,7 +125,7 @@ public class Library : AggregateRoot<LibraryId>
/// <param name="contentLocations">The list of file system paths that make up the media library.</param> /// <param name="contentLocations">The list of file system paths that make up the media library.</param>
/// <param name="coverImageSourcePath">The path of the image file chosen by the user to be used as the cover for the library.</param> /// <param name="coverImageSourcePath">The path of the image file chosen by the user to be used as the cover for the library.</param>
/// <returns> /// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="Library"/>, or an error message. /// An <see cref="ErrorOr{TValue}"/> containing either a successfuly created <see cref="Library"/>, or an error message.
/// </returns> /// </returns>
public static ErrorOr<Library> Create( public static ErrorOr<Library> Create(
LibraryId id, LibraryId id,
@@ -161,4 +162,20 @@ public class Library : AggregateRoot<LibraryId>
{ {
CoverImage = path; CoverImage = path;
} }
/// <summary>
/// Marks the current library as deleted.
/// </summary>
public ErrorOr<Deleted> Delete()
{
// clear all existing events since they become irrelevant when the entity is deleted, and they dont need to be processed
_domainEvents.Clear();
// only add the delete event if it hasn't been added already
if (!_domainEvents.Any(e => e is LibraryDeletedDomainEvent))
_domainEvents.Add(new LibraryDeletedDomainEvent(Guid.NewGuid(), this, DateTime.UtcNow));
// TODO: perhaps trigger events for removing contents related to the removed library (media metadata, etc)?
return Result.Deleted;
}
} }
@@ -35,7 +35,7 @@ public sealed class User : AggregateRoot<UserId>
/// </summary> /// </summary>
/// <param name="username">The username of the user.</param> /// <param name="username">The username of the user.</param>
/// <returns> /// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="User"/>, or an error message. /// An <see cref="ErrorOr{TValue}"/> containing either a successfuly created <see cref="User"/>, or an error message.
/// </returns> /// </returns>
public static ErrorOr<User> Create( public static ErrorOr<User> Create(
string username) string username)
@@ -51,7 +51,7 @@ public sealed class User : AggregateRoot<UserId>
/// <param name="id">The object representing the id of the user.</param> /// <param name="id">The object representing the id of the user.</param>
/// <param name="username">The username of the user.</param> /// <param name="username">The username of the user.</param>
/// <returns> /// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="User"/>, or an error message. /// An <see cref="ErrorOr{TValue}"/> containing either a successfuly created <see cref="User"/>, or an error message.
/// </returns> /// </returns>
public static ErrorOr<User> Create( public static ErrorOr<User> Create(
UserId id, UserId id,
@@ -96,7 +96,7 @@ public class VideoMetadata : BaseMetadata
/// <param name="genres">The genres of the video.</param> /// <param name="genres">The genres of the video.</param>
/// <param name="tags">The tags associated with the video.</param> /// <param name="tags">The tags associated with the video.</param>
/// <returns> /// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="VideoMetadata"/>, or an error message. /// An <see cref="ErrorOr{TValue}"/> containing either a successfuly created <see cref="VideoMetadata"/>, or an error message.
/// </returns> /// </returns>
public static ErrorOr<VideoMetadata> Create( public static ErrorOr<VideoMetadata> Create(
string title, string title,
@@ -206,7 +206,7 @@ public sealed class Book : AggregateRoot<BookId>
/// <param name="contributors">The list of media contributors of the book.</param> /// <param name="contributors">The list of media contributors of the book.</param>
/// <param name="ratings">The list of ratings for the book.</param> /// <param name="ratings">The list of ratings for the book.</param>
/// <returns> /// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="Book"/>, or an error message. /// An <see cref="ErrorOr{TValue}"/> containing either a successfuly created <see cref="Book"/>, or an error message.
/// </returns> /// </returns>
public static ErrorOr<Book> Create( public static ErrorOr<Book> Create(
WrittenContentMetadata metadata, WrittenContentMetadata metadata,
@@ -276,7 +276,7 @@ public sealed class Book : AggregateRoot<BookId>
/// <param name="contributors">The list of media contributors of the book.</param> /// <param name="contributors">The list of media contributors of the book.</param>
/// <param name="ratings">The list of ratings for the book.</param> /// <param name="ratings">The list of ratings for the book.</param>
/// <returns> /// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="Book"/>, or an error message. /// An <see cref="ErrorOr{TValue}"/> containing either a successfuly created <see cref="Book"/>, or an error message.
/// </returns> /// </returns>
public static ErrorOr<Book> Create( public static ErrorOr<Book> Create(
BookId id, BookId id,
@@ -56,7 +56,7 @@ public sealed class BookSeries : Entity<BookSeriesId>
/// <param name="isComplete">The current status of the book series.</param> /// <param name="isComplete">The current status of the book series.</param>
/// <param name="books">The books of the book series.</param> /// <param name="books">The books of the book series.</param>
/// <returns> /// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="BookSeries"/>, or an error message. /// An <see cref="ErrorOr{TValue}"/> containing either a successfuly created <see cref="BookSeries"/>, or an error message.
/// </returns> /// </returns>
public static ErrorOr<BookSeries> Create( public static ErrorOr<BookSeries> Create(
BookSeriesId id, BookSeriesId id,
@@ -80,7 +80,7 @@ public sealed class BookSeries : Entity<BookSeriesId>
/// <param name="isComplete">The current status of the book series.</param> /// <param name="isComplete">The current status of the book series.</param>
/// <param name="books">The books of the book series.</param> /// <param name="books">The books of the book series.</param>
/// <returns> /// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="BookSeries"/>, or an error message. /// An <see cref="ErrorOr{TValue}"/> containing either a successfuly created <see cref="BookSeries"/>, or an error message.
/// </returns> /// </returns>
public static ErrorOr<BookSeries> Create( public static ErrorOr<BookSeries> Create(
WrittenContentMetadata metadata, WrittenContentMetadata metadata,
@@ -42,7 +42,7 @@ public class BookRating : Rating
/// <param name="source">The optional source of the rating.</param> /// <param name="source">The optional source of the rating.</param>
/// <param name="voteCount">The optional number of votes or reviews.</param> /// <param name="voteCount">The optional number of votes or reviews.</param>
/// <returns> /// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="Rating"/>, or an error message. /// An <see cref="ErrorOr{TValue}"/> containing either a successfuly created <see cref="Rating"/>, or an error message.
/// </returns> /// </returns>
public static ErrorOr<BookRating> Create(decimal value, decimal maxValue, Optional<BookRatingSource> source, Optional<int> voteCount) public static ErrorOr<BookRating> Create(decimal value, decimal maxValue, Optional<BookRatingSource> source, Optional<int> voteCount)
{ {
@@ -69,7 +69,7 @@ public class WrittenContentMetadata : BaseMetadata
/// <param name="publisher">The publisher of the written content, if applicable.</param> /// <param name="publisher">The publisher of the written content, if applicable.</param>
/// <param name="pageCount">The number of pages in the written content, if applicable.</param> /// <param name="pageCount">The number of pages in the written content, if applicable.</param>
/// <returns> /// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="WrittenContentMetadata"/>, or an error message. /// An <see cref="ErrorOr{TValue}"/> containing either a successfuly created <see cref="WrittenContentMetadata"/>, or an error message.
/// </returns> /// </returns>
public static ErrorOr<WrittenContentMetadata> Create( public static ErrorOr<WrittenContentMetadata> Create(
string title, string title,
@@ -13,7 +13,7 @@ using System.Threading.Tasks;
namespace Lumina.Presentation.Api.Common.Middlewares; namespace Lumina.Presentation.Api.Common.Middlewares;
/// <summary> /// <summary>
/// Middleware that ensures eventual consistency by handling domain events and publishing them after the request has completed successfully. /// Middleware that ensures eventual consistency by handling domain events and publishing them after the request has completed successfuly.
/// </summary> /// </summary>
public class EventualConsistencyMiddleware public class EventualConsistencyMiddleware
{ {
@@ -24,6 +24,7 @@ public class EventualConsistencyMiddleware
/// Initializes a new instance of the <see cref="EventualConsistencyMiddleware"/> class. /// Initializes a new instance of the <see cref="EventualConsistencyMiddleware"/> class.
/// </summary> /// </summary>
/// <param name="next">The next middleware in the HTTP request pipeline.</param> /// <param name="next">The next middleware in the HTTP request pipeline.</param>
/// <param name="logger">Injected service for logging.</param>
public EventualConsistencyMiddleware(RequestDelegate next, ILogger<EventualConsistencyMiddleware> logger) public EventualConsistencyMiddleware(RequestDelegate next, ILogger<EventualConsistencyMiddleware> logger)
{ {
_next = next; _next = next;
@@ -14,5 +14,6 @@ public static partial class ApiRoutes
public const string GET_LIBRARIES = "/libraries"; public const string GET_LIBRARIES = "/libraries";
public const string ADD_LIBRARY = "/libraries"; public const string ADD_LIBRARY = "/libraries";
public const string UPDATE_LIBRARY = "/libraries/{id}"; public const string UPDATE_LIBRARY = "/libraries/{id}";
public const string DELETE_LIBRARY = "/libraries/{id}";
} }
} }
@@ -40,7 +40,7 @@ public class AddRoleEndpointSummary : Summary<AddRoleEndpoint, AddRoleRequest>
ResponseParam<RolePermissionsResponse>(r => r.Permissions, "The list of permissions of the role entity."); ResponseParam<RolePermissionsResponse>(r => r.Permissions, "The list of permissions of the role entity.");
Response(200, "The authorization role was successfully created.", example: Response(200, "The authorization role was successfuly created.", example:
new RolePermissionsResponse( new RolePermissionsResponse(
Role: new RoleDto(Id: Guid.NewGuid(), "Editor"), Role: new RoleDto(Id: Guid.NewGuid(), "Editor"),
Permissions: [new PermissionDto(Guid.NewGuid(), AuthorizationPermission.CanDeleteUsers), new PermissionDto(Guid.NewGuid(), AuthorizationPermission.CanViewUsers)] Permissions: [new PermissionDto(Guid.NewGuid(), AuthorizationPermission.CanDeleteUsers), new PermissionDto(Guid.NewGuid(), AuthorizationPermission.CanViewUsers)]
@@ -30,7 +30,7 @@ public class DeleteRoleEndpointSummary : Summary<DeleteRoleEndpoint, DeleteRoleR
RequestParam(r => r.RoleId, "The Id of the role. Required."); RequestParam(r => r.RoleId, "The Id of the role. Required.");
Response(204, "The authorization role was successfully deleted."); Response(204, "The authorization role was successfuly deleted.");
Response(401, "Authentication required.", "application/problem+json", Response(401, "Authentication required.", "application/problem+json",
example: new[] example: new[]
@@ -42,7 +42,7 @@ public class UpdateRoleEndpointSummary : Summary<UpdateRoleEndpoint, UpdateRoleR
ResponseParam<RolePermissionsResponse>(r => r.Permissions, "The list of permissions of the role entity."); ResponseParam<RolePermissionsResponse>(r => r.Permissions, "The list of permissions of the role entity.");
Response(200, "The authorization role was successfully updated.", example: Response(200, "The authorization role was successfuly updated.", example:
new RolePermissionsResponse( new RolePermissionsResponse(
Role: new RoleDto(Id: Guid.NewGuid(), "Editor"), Role: new RoleDto(Id: Guid.NewGuid(), "Editor"),
Permissions: [new PermissionDto(Guid.NewGuid(), AuthorizationPermission.CanDeleteUsers), new PermissionDto(Guid.NewGuid(), AuthorizationPermission.CanViewUsers)] Permissions: [new PermissionDto(Guid.NewGuid(), AuthorizationPermission.CanDeleteUsers), new PermissionDto(Guid.NewGuid(), AuthorizationPermission.CanViewUsers)]
@@ -28,7 +28,7 @@ public class SplitPathEndpointSummary : Summary<SplitPathEndpoint, SplitPathRequ
RequestParam(r => r.Path, "The file system path for which to get the path segments. Required."); RequestParam(r => r.Path, "The file system path for which to get the path segments. Required.");
Response(200, "Successfully split the path into segments.", Response(200, "successfuly split the path into segments.",
example: new PathSegmentResponse[2] { example: new PathSegmentResponse[2] {
new(Path: "media"), new(Path: "media"),
new(Path: "movies") new(Path: "movies")
@@ -49,7 +49,7 @@ public class AddLibraryEndpointSummary : Summary<AddLibraryEndpoint, AddLibraryR
ResponseParam<LibraryResponse>(r => r.UpdatedOnUtc, "The date and time when the entity was last updated."); ResponseParam<LibraryResponse>(r => r.UpdatedOnUtc, "The date and time when the entity was last updated.");
Response(201, "The media library was successfully created.", example: Response(201, "The media library was successfuly created.", example:
new LibraryResponse( new LibraryResponse(
Id: Guid.NewGuid(), Id: Guid.NewGuid(),
UserId: Guid.NewGuid(), UserId: Guid.NewGuid(),
@@ -0,0 +1,53 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using FastEndpoints;
using Lumina.Contracts.Requests.MediaLibrary.Management;
using Lumina.Presentation.Api.Common.Routes.Library.Management;
using Lumina.Presentation.Api.Core.Endpoints.Common;
using Mediator;
using Microsoft.AspNetCore.Http;
using Lumina.Application.Common.Mapping.MediaLibrary.Management;
using System.Threading;
using System.Threading.Tasks;
#endregion
namespace Lumina.Presentation.Api.Core.Endpoints.Library.Management.DeleteLibrary;
/// <summary>
/// API endpoint for the <c>//libraries/{id}</c> route.
/// </summary>
public class DeleteLibraryEndpoint : BaseEndpoint<DeleteLibraryRequest, IResult>
{
private readonly ISender _sender;
/// <summary>
/// Initializes a new instance of the <see cref="DeleteLibraryEndpoint"/> class.
/// </summary>
/// <param name="sender">Injected service for mediating commands and queries.</param>
public DeleteLibraryEndpoint(ISender sender)
{
_sender = sender;
}
/// <summary>
/// Configures the API endpoint.
/// </summary>
public override void Configure()
{
Verbs(Http.DELETE);
Routes(ApiRoutes.Libraries.DELETE_LIBRARY);
Version(1);
DontCatchExceptions();
}
/// <summary>
/// Deletes a library by Id.
/// </summary>
/// <param name="request">The request containing the id of the library to be deleted.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
public override async Task<IResult> ExecuteAsync(DeleteLibraryRequest request, CancellationToken cancellationToken)
{
ErrorOr<Deleted> result = await _sender.Send(request.ToCommand(), cancellationToken).ConfigureAwait(false);
return result.Match(success => TypedResults.Ok(success), Problem);
}
}
@@ -0,0 +1,53 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using FastEndpoints;
using Lumina.Application.Core.MediaLibrary.Management.Queries.GetLibraries;
using Lumina.Contracts.Responses.MediaLibrary.Management;
using Lumina.Presentation.Api.Common.Routes.Library.Management;
using Lumina.Presentation.Api.Core.Endpoints.Common;
using Mediator;
using Microsoft.AspNetCore.Http;
using System.Threading;
using System.Threading.Tasks;
#endregion
namespace Lumina.Presentation.Api.Core.Endpoints.Library.Management.GetLibraries;
/// <summary>
/// API endpoint for the <c>/libraries</c> route.
/// </summary>
public class GetLibrariesEndpoint : BaseEndpoint<EmptyRequest, IResult>
{
private readonly ISender _sender;
/// <summary>
/// Initializes a new instance of the <see cref="GetLibrariesEndpoint"/> class.
/// </summary>
/// <param name="sender">Injected service for mediating commands and queries.</param>
public GetLibrariesEndpoint(ISender sender)
{
_sender = sender;
}
/// <summary>
/// Configures the API endpoint.
/// </summary>
public override void Configure()
{
Verbs(Http.GET);
Routes(ApiRoutes.Libraries.GET_LIBRARIES);
Version(1);
DontCatchExceptions();
}
/// <summary>
/// Gets the list of libraries.
/// </summary>
/// <param name="request">The request containing the id of the library to be retrieved.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
public override async Task<IResult> ExecuteAsync(EmptyRequest _, CancellationToken cancellationToken)
{
ErrorOr<LibraryResponse[]> result = await _sender.Send(new GetLibrariesQuery(), cancellationToken).ConfigureAwait(false);
return result.Match(success => TypedResults.Ok(success), Problem);
}
}
@@ -0,0 +1,80 @@
#region ========================================================================= USING =====================================================================================
using FastEndpoints;
using Lumina.Contracts.Responses.MediaLibrary.Management;
using Lumina.Domain.Common.Enums.MediaLibrary;
using System;
using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Presentation.Api.Core.Endpoints.Library.Management.GetLibraries;
/// <summary>
/// Class used for providing a textual description for the <see cref="GetLibrariesEndpoint"/> API endpoint, for OpenAPI.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetLibrariesEndpointSummary : Summary<GetLibrariesEndpoint, EmptyRequest>
{
/// <summary>
/// Initializes a new instance of the <see cref="GetLibrariesEndpointSummary"/> class.
/// </summary>
public GetLibrariesEndpointSummary()
{
Summary = "Retrieves the list of media libraries.";
Description = "Retrieves the entire list of media libraries, if the user making the request is an Admin, or just the library owned by them, for regular users.";
Response(200, "The media libraries are returned.",
example: new LibraryResponse[] {
new (
Id: Guid.NewGuid(),
UserId: Guid.NewGuid(),
Title: "TV Shows",
LibraryType: LibraryType.TvShow,
ContentLocations: ["/media/tv shows/drama/", "/media/tv shows/SCI-FI/"],
CoverImage: "/media/myTvShowPoster.jpg",
CreatedOnUtc: DateTime.UtcNow,
UpdatedOnUtc: default
),
new (
Id: Guid.NewGuid(),
UserId: Guid.NewGuid(),
Title: "Movies",
LibraryType: LibraryType.TvShow,
ContentLocations: ["/media/movies/"],
CoverImage: "/media/myMoviePoster.jpg",
CreatedOnUtc: DateTime.UtcNow,
UpdatedOnUtc: default
)
});
Response(401, "Authentication required.", "application/problem+json",
example: new[]
{
new
{
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
status = 401,
title = "Unauthorized",
detail = "You are not authorized",
instance = "/api/v1/libraries"
},
new
{
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
status = 401,
title = "Unauthorized",
detail = "Invalid token: The token expired at '01/01/2024 01:00:00'",
instance = "/api/v1/libraries"
},
new
{
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
status = 401,
title = "Unauthorized",
detail = "The token is invalid",
instance = "/api/v1/libraries"
}
}
);
}
}
@@ -8,8 +8,6 @@ using Lumina.Presentation.Api.Common.Routes.Library.Management;
using Lumina.Presentation.Api.Core.Endpoints.Common; using Lumina.Presentation.Api.Core.Endpoints.Common;
using Mediator; using Mediator;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using System;
using System.Security.Claims;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
#endregion #endregion
@@ -50,9 +48,7 @@ public class GetLibraryEndpoint : BaseEndpoint<GetLibraryRequest, IResult>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param> /// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
public override async Task<IResult> ExecuteAsync(GetLibraryRequest request, CancellationToken cancellationToken) public override async Task<IResult> ExecuteAsync(GetLibraryRequest request, CancellationToken cancellationToken)
{ {
// retrieve the currently authenticated user, and send it with the request ErrorOr<LibraryResponse> result = await _sender.Send(request.ToQuery(), cancellationToken).ConfigureAwait(false);
string? user = User.FindFirstValue(ClaimTypes.NameIdentifier);
ErrorOr<LibraryResponse> result = await _sender.Send(request.ToQuery(Guid.Parse(user!)), cancellationToken).ConfigureAwait(false);
return result.Match(success => TypedResults.Ok(success), Problem); return result.Match(success => TypedResults.Ok(success), Problem);
} }
} }
@@ -53,7 +53,7 @@ public class UpdateLibraryEndpointSummary : Summary<UpdateLibraryEndpoint, Updat
ResponseParam<LibraryResponse>(r => r.UpdatedOnUtc, "The date and time when the entity was last updated."); ResponseParam<LibraryResponse>(r => r.UpdatedOnUtc, "The date and time when the entity was last updated.");
Response(200, "The media library was successfully updated.", example: Response(200, "The media library was successfuly updated.", example:
new LibraryResponse( new LibraryResponse(
Id: Guid.NewGuid(), Id: Guid.NewGuid(),
UserId: Guid.NewGuid(), UserId: Guid.NewGuid(),
@@ -265,6 +265,5 @@ public class GetBooksEndpointSummary : Summary<GetBooksEndpoint>
} }
} }
); );
} }
} }
@@ -43,7 +43,7 @@ public class UpdateUserRoleAndPermissionsEndpointSummary : Summary<UpdateUserRol
ResponseParam<AuthorizationResponse>(r => r.Permissions, "The list of permissions of the user."); ResponseParam<AuthorizationResponse>(r => r.Permissions, "The list of permissions of the user.");
Response(200, "The authorization role and permissions of the user were successfully updated.", example: Response(200, "The authorization role and permissions of the user were successfuly updated.", example:
new AuthorizationResponse( new AuthorizationResponse(
UserId: Guid.NewGuid(), UserId: Guid.NewGuid(),
Role: "Editor", Role: "Editor",
@@ -9,5 +9,5 @@ public enum AuthorizationPermission
CanViewUsers, CanViewUsers,
CanDeleteUsers, CanDeleteUsers,
CanRegisterUsers, CanRegisterUsers,
canCreateLibraries CanCreateLibraries
} }
@@ -1,5 +1,7 @@
#region ========================================================================= USING ===================================================================================== #region ========================================================================= USING =====================================================================================
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Localization;
using Microsoft.Extensions.Logging;
using System.Threading.Tasks; using System.Threading.Tasks;
#endregion #endregion
@@ -11,14 +13,17 @@ namespace Lumina.Presentation.Web.Common.Middlewares;
public class NotFoundRedirectMiddleware public class NotFoundRedirectMiddleware
{ {
private readonly RequestDelegate _next; private readonly RequestDelegate _next;
private readonly ILogger<NotFoundRedirectMiddleware> _logger;
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="NotFoundRedirectMiddleware"/> class. /// Initializes a new instance of the <see cref="NotFoundRedirectMiddleware"/> class.
/// </summary> /// </summary>
/// <param name="next">The next middleware in the request pipeline.</param> /// <param name="next">The next middleware in the request pipeline.</param>
public NotFoundRedirectMiddleware(RequestDelegate next) /// <param name="logger">Injected service for logging.</param>
public NotFoundRedirectMiddleware(RequestDelegate next, ILogger<NotFoundRedirectMiddleware> logger)
{ {
_next = next; _next = next;
_logger = logger;
} }
/// <summary> /// <summary>
@@ -31,13 +36,15 @@ public class NotFoundRedirectMiddleware
if (context.Response.StatusCode == 404 && !context.Response.HasStarted) if (context.Response.StatusCode == 404 && !context.Response.HasStarted)
{ {
string culture = context.Request.RouteValues["culture"]?.ToString()?.ToLower() ?? "en-us"; string culture = context.Request.RouteValues["culture"]?.ToString()?.ToLower() ??
string notFoundUrl = $"/{culture}/not-found"; context.Features.Get<IRequestCultureFeature>()?.RequestCulture.Culture.Name?.ToLower() ??
"en-us";
// re-execute the request so the user gets the error page // re-execute the request so the user gets the error page
string? originalPath = context.Request.Path.Value; string? originalPath = context.Request.Path.Value;
context.Items["originalPath"] = originalPath; context.Items["originalPath"] = originalPath;
context.Request.Path = notFoundUrl; _logger.LogInformation("Redirecting user to NotFound url");
context.Request.Path = $"/{culture}/not-found";
await _next(context); await _next(context);
} }
} }
@@ -12,8 +12,11 @@ using System.Threading.Tasks;
namespace Lumina.Presentation.Web.Controllers.Library.Management; namespace Lumina.Presentation.Web.Controllers.Library.Management;
/// <summary>
/// Controller for media libraries related operations.
/// </summary>
[Authorize] [Authorize]
[Route("{culture}/library/manage")] [Route("{culture}/libraries/manage")]
public class LibraryManagementController : Controller public class LibraryManagementController : Controller
{ {
private readonly IApiHttpClient _apiHttpClient; private readonly IApiHttpClient _apiHttpClient;
@@ -30,6 +33,7 @@ public class LibraryManagementController : Controller
/// <summary> /// <summary>
/// Displays the view for displaying the list of media libraries. /// Displays the view for displaying the list of media libraries.
/// </summary> /// </summary>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
[HttpGet("")] [HttpGet("")]
public IActionResult Index() public IActionResult Index()
{ {
@@ -42,8 +46,8 @@ public class LibraryManagementController : Controller
[HttpGet("item")] [HttpGet("item")]
public IActionResult AddLibrary() public IActionResult AddLibrary()
{ {
LibraryModel libraryModel = new(); LibraryModel library = new();
return View("/Views/Library/Management/Item.cshtml", libraryModel); return View("/Views/Library/Management/Item.cshtml", library);
} }
/// <summary> /// <summary>
@@ -54,8 +58,19 @@ public class LibraryManagementController : Controller
[HttpGet("item/{id}")] [HttpGet("item/{id}")]
public async Task<IActionResult> EditLibrary(Guid id, CancellationToken cancellationToken = default) public async Task<IActionResult> EditLibrary(Guid id, CancellationToken cancellationToken = default)
{ {
LibraryModel libraryModel = await _apiHttpClient.GetAsync<LibraryModel>($"libraries/{id}", cancellationToken).ConfigureAwait(false); LibraryModel response = await _apiHttpClient.GetAsync<LibraryModel>($"libraries/{id}", cancellationToken).ConfigureAwait(false);
return View("/Views/Library/Management/Item.cshtml", libraryModel); return View("/Views/Library/Management/Item.cshtml", response);
}
/// <summary>
/// Gets the list of media libraries.
/// </summary>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
[HttpGet("api-get-libraries")]
public async Task<IActionResult> GetLibraries(CancellationToken cancellationToken = default)
{
LibraryModel[] response = await _apiHttpClient.GetAsync<LibraryModel[]>($"libraries/", cancellationToken).ConfigureAwait(false);
return Json(new { success = true, data = response });
} }
/// <summary> /// <summary>
@@ -65,7 +80,7 @@ public class LibraryManagementController : Controller
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param> /// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
[ValidateAntiForgeryToken] [ValidateAntiForgeryToken]
[HttpPost("api-item")] [HttpPost("api-item")]
[RequirePermission(AuthorizationPermission.canCreateLibraries)] [RequirePermission(AuthorizationPermission.CanCreateLibraries)]
public async Task<IActionResult> SaveLibrary([FromBody] LibraryModel data, CancellationToken cancellationToken) public async Task<IActionResult> SaveLibrary([FromBody] LibraryModel data, CancellationToken cancellationToken)
{ {
// call different API endpoints based on whether this is a new library or an existing one // call different API endpoints based on whether this is a new library or an existing one
@@ -74,4 +89,16 @@ public class LibraryManagementController : Controller
: await _apiHttpClient.PostAsync<LibraryModel, LibraryModel>("libraries", data, cancellationToken).ConfigureAwait(false); : await _apiHttpClient.PostAsync<LibraryModel, LibraryModel>("libraries", data, cancellationToken).ConfigureAwait(false);
return Json(new { success = true, data = response }); return Json(new { success = true, data = response });
} }
/// <summary>
/// Deletes a media library.
/// </summary>
/// <param name="id">The id of the media library to delete.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
[HttpDelete("api-item/{id}")]
public async Task<IActionResult> DeleteLibrary(Guid id, CancellationToken cancellationToken = default)
{
await _apiHttpClient.DeleteAsync($"libraries/{id}", cancellationToken).ConfigureAwait(false);
return Json(new { success = true });
}
} }
@@ -117,6 +117,9 @@
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<data name="CanCreateLibraries" xml:space="preserve">
<value>Kann Mediatheken erstellen</value>
</data>
<data name="CanDeleteUsers" xml:space="preserve"> <data name="CanDeleteUsers" xml:space="preserve">
<value>Kann Benutzer löschen</value> <value>Kann Benutzer löschen</value>
</data> </data>
@@ -117,6 +117,9 @@
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<data name="CanCreateLibraries" xml:space="preserve">
<value>Can create libraries</value>
</data>
<data name="CanDeleteUsers" xml:space="preserve"> <data name="CanDeleteUsers" xml:space="preserve">
<value>Can delete users</value> <value>Can delete users</value>
</data> </data>
@@ -117,6 +117,9 @@
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<data name="CanCreateLibraries" xml:space="preserve">
<value>Puede crear bibliotecas</value>
</data>
<data name="CanDeleteUsers" xml:space="preserve"> <data name="CanDeleteUsers" xml:space="preserve">
<value>Puede eliminar usuarios</value> <value>Puede eliminar usuarios</value>
</data> </data>
@@ -117,6 +117,9 @@
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<data name="CanCreateLibraries" xml:space="preserve">
<value>Peut créer des médiathèques</value>
</data>
<data name="CanDeleteUsers" xml:space="preserve"> <data name="CanDeleteUsers" xml:space="preserve">
<value>Peut supprimer des utilisateurs</value> <value>Peut supprimer des utilisateurs</value>
</data> </data>
@@ -117,6 +117,9 @@
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<data name="CanCreateLibraries" xml:space="preserve">
<value>Può creare librerie</value>
</data>
<data name="CanDeleteUsers" xml:space="preserve"> <data name="CanDeleteUsers" xml:space="preserve">
<value>Può eliminare utenti</value> <value>Può eliminare utenti</value>
</data> </data>
@@ -117,6 +117,9 @@
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<data name="CanCreateLibraries" xml:space="preserve">
<value>ライブラリを作成可能</value>
</data>
<data name="CanDeleteUsers" xml:space="preserve"> <data name="CanDeleteUsers" xml:space="preserve">
<value>ユーザーを削除できます</value> <value>ユーザーを削除できます</value>
</data> </data>
@@ -117,6 +117,9 @@
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<data name="CanCreateLibraries" xml:space="preserve">
<value>Can create libraries</value>
</data>
<data name="CanDeleteUsers" xml:space="preserve"> <data name="CanDeleteUsers" xml:space="preserve">
<value>Can delete users</value> <value>Can delete users</value>
</data> </data>
@@ -117,6 +117,9 @@
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<data name="CanCreateLibraries" xml:space="preserve">
<value>Poate crea biblioteci</value>
</data>
<data name="CanDeleteUsers" xml:space="preserve"> <data name="CanDeleteUsers" xml:space="preserve">
<value>Poate șterge utilizatori</value> <value>Poate șterge utilizatori</value>
</data> </data>
@@ -117,6 +117,9 @@
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<data name="CanCreateLibraries" xml:space="preserve">
<value>Может создавать библиотеки</value>
</data>
<data name="CanDeleteUsers" xml:space="preserve"> <data name="CanDeleteUsers" xml:space="preserve">
<value>Может удалять пользователей</value> <value>Может удалять пользователей</value>
</data> </data>
@@ -117,6 +117,9 @@
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<data name="CanCreateLibraries" xml:space="preserve">
<value>可以创建媒体库</value>
</data>
<data name="CanDeleteUsers" xml:space="preserve"> <data name="CanDeleteUsers" xml:space="preserve">
<value>可以删除用户</value> <value>可以删除用户</value>
</data> </data>
@@ -117,6 +117,9 @@
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<data name="CanCreateLibraries" xml:space="preserve">
<value>Kann Mediatheken erstellen</value>
</data>
<data name="CanDeleteUsers" xml:space="preserve"> <data name="CanDeleteUsers" xml:space="preserve">
<value>Kann Benutzer löschen</value> <value>Kann Benutzer löschen</value>
</data> </data>
@@ -117,6 +117,9 @@
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<data name="CanCreateLibraries" xml:space="preserve">
<value>Can create libraries</value>
</data>
<data name="CanDeleteUsers" xml:space="preserve"> <data name="CanDeleteUsers" xml:space="preserve">
<value>Can delete users</value> <value>Can delete users</value>
</data> </data>
@@ -117,6 +117,9 @@
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<data name="CanCreateLibraries" xml:space="preserve">
<value>Puede crear bibliotecas</value>
</data>
<data name="CanDeleteUsers" xml:space="preserve"> <data name="CanDeleteUsers" xml:space="preserve">
<value>Puede eliminar usuarios</value> <value>Puede eliminar usuarios</value>
</data> </data>
@@ -117,6 +117,9 @@
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<data name="CanCreateLibraries" xml:space="preserve">
<value>Peut créer des médiathèques</value>
</data>
<data name="CanDeleteUsers" xml:space="preserve"> <data name="CanDeleteUsers" xml:space="preserve">
<value>Peut supprimer des utilisateurs</value> <value>Peut supprimer des utilisateurs</value>
</data> </data>
@@ -117,6 +117,9 @@
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<data name="CanCreateLibraries" xml:space="preserve">
<value>Può creare librerie</value>
</data>
<data name="CanDeleteUsers" xml:space="preserve"> <data name="CanDeleteUsers" xml:space="preserve">
<value>Può eliminare utenti</value> <value>Può eliminare utenti</value>
</data> </data>
Loaded 100 of 162 files, more files were not shown because too many files have changed in this diff. Show more