diff --git a/src/Lumina.Application/Common/DataAccess/Repositories/MediaLibrary/ILibraryRepository.cs b/src/Lumina.Application/Common/DataAccess/Repositories/MediaLibrary/ILibraryRepository.cs index d1e39a1b..67025750 100644 --- a/src/Lumina.Application/Common/DataAccess/Repositories/MediaLibrary/ILibraryRepository.cs +++ b/src/Lumina.Application/Common/DataAccess/Repositories/MediaLibrary/ILibraryRepository.cs @@ -1,7 +1,8 @@ #region ========================================================================= USING ===================================================================================== +using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management; using Lumina.Application.Common.DataAccess.Repositories.Common.Actions; using Lumina.Application.Common.DataAccess.Repositories.Common.Base; -using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management; +using System; #endregion namespace Lumina.Application.Common.DataAccess.Repositories.MediaLibrary; @@ -10,6 +11,8 @@ namespace Lumina.Application.Common.DataAccess.Repositories.MediaLibrary; /// Interface for the repository for media libraries. /// public interface ILibraryRepository : IRepository, - IInsertRepositoryAction + IGetByIdRepositoryAction, + IInsertRepositoryAction, + IUpdateRepositoryAction { } diff --git a/src/Lumina.Application/Common/Errors/Errors.Authorization.cs b/src/Lumina.Application/Common/Errors/Errors.Authorization.cs index 842f394f..159d200f 100644 --- a/src/Lumina.Application/Common/Errors/Errors.Authorization.cs +++ b/src/Lumina.Application/Common/Errors/Errors.Authorization.cs @@ -11,6 +11,7 @@ public static partial class Errors { public static class Authorization { + public static Error NotAuthorized => Error.Unauthorized(description: nameof(NotAuthorized)); public static Error AdminAccountAlreadyCreated => Error.Unauthorized(description: nameof(AdminAccountAlreadyCreated)); } } diff --git a/src/Lumina.Application/Common/Errors/Errors.Persistence.cs b/src/Lumina.Application/Common/Errors/Errors.Persistence.cs new file mode 100644 index 00000000..f487eaa0 --- /dev/null +++ b/src/Lumina.Application/Common/Errors/Errors.Persistence.cs @@ -0,0 +1,16 @@ +#region ========================================================================= USING ===================================================================================== +using ErrorOr; +#endregion + +namespace Lumina.Application.Common.Errors; + +/// +/// Application persistence related error types. +/// +public static partial class Errors +{ + public static class Persistence + { + public static Error ErrorPersistingMediaLibrary => Error.Failure(description: nameof(ErrorPersistingMediaLibrary)); + } +} diff --git a/src/Lumina.Application/Common/Mapping/MediaLibrary/Management/AddMediaLibraryRequestMapping.cs b/src/Lumina.Application/Common/Mapping/MediaLibrary/Management/AddMediaLibraryRequestMapping.cs index 4251f38a..94a05159 100644 --- a/src/Lumina.Application/Common/Mapping/MediaLibrary/Management/AddMediaLibraryRequestMapping.cs +++ b/src/Lumina.Application/Common/Mapping/MediaLibrary/Management/AddMediaLibraryRequestMapping.cs @@ -2,6 +2,7 @@ using Lumina.Application.Core.MediaLibrary.Management.Commands.AddLibrary; using Lumina.Application.Core.MediaLibrary.WrittenContentLibrary.BooksLibrary.Books.Commands.AddBook; using Lumina.Contracts.Requests.MediaLibrary.Management; +using Lumina.Domain.Common.Enums.MediaLibrary; using System; #endregion @@ -16,7 +17,7 @@ public static class AddMediaLibraryRequestMapping /// Converts to . /// /// The request to be converted. - /// The Id of the user owning the media library. Required. + /// The Id of the user owning the media library. /// The converted command. public static AddLibraryCommand ToCommand(this AddLibraryRequest request, Guid userId) { diff --git a/src/Lumina.Application/Common/Mapping/MediaLibrary/Management/GetLibraryRequestMapping.cs b/src/Lumina.Application/Common/Mapping/MediaLibrary/Management/GetLibraryRequestMapping.cs new file mode 100644 index 00000000..6122e0b5 --- /dev/null +++ b/src/Lumina.Application/Common/Mapping/MediaLibrary/Management/GetLibraryRequestMapping.cs @@ -0,0 +1,27 @@ +#region ========================================================================= USING ===================================================================================== +using Lumina.Application.Core.MediaLibrary.Management.Queries; +using Lumina.Contracts.Requests.MediaLibrary.Management; +using System; +#endregion + +namespace Lumina.Application.Common.Mapping.MediaLibrary.Management; + +/// +/// Extension methods for converting . +/// +public static class GetLibraryRequestMapping +{ + /// + /// Converts to . + /// + /// The request to be converted. + /// The Id of the user requesting the media library. + /// The converted query. + public static GetLibraryQuery ToQuery(this GetLibraryRequest request, Guid userId) + { + return new GetLibraryQuery( + request.Id, + userId + ); + } +} diff --git a/src/Lumina.Application/Common/Mapping/MediaLibrary/Management/UpdateLibraryRequestMapping.cs b/src/Lumina.Application/Common/Mapping/MediaLibrary/Management/UpdateLibraryRequestMapping.cs new file mode 100644 index 00000000..2fa3a323 --- /dev/null +++ b/src/Lumina.Application/Common/Mapping/MediaLibrary/Management/UpdateLibraryRequestMapping.cs @@ -0,0 +1,31 @@ +#region ========================================================================= USING ===================================================================================== +using Lumina.Application.Core.MediaLibrary.Management.Commands.UpdateLibrary; +using Lumina.Contracts.Requests.MediaLibrary.Management; +using System; +#endregion + +namespace Lumina.Application.Common.Mapping.MediaLibrary.Management; + +/// +/// Extension methods for converting . +/// +public static class UpdateLibraryRequestMapping +{ + /// + /// Converts to . + /// + /// The request to be converted. + /// The Id of the user making the request to update the media library. + /// The converted command. + public static UpdateLibraryCommand ToCommand(this UpdateLibraryRequest request, Guid userId) + { + return new UpdateLibraryCommand( + request.Id, + request.UserId, + userId, + request.Title, + request.LibraryType, + request.ContentLocations + ); + } +} diff --git a/src/Lumina.Application/Core/MediaLibrary/Management/Commands/AddLibrary/AddLibraryCommand.cs b/src/Lumina.Application/Core/MediaLibrary/Management/Commands/AddLibrary/AddLibraryCommand.cs index 067a0519..62c2dc0c 100644 --- a/src/Lumina.Application/Core/MediaLibrary/Management/Commands/AddLibrary/AddLibraryCommand.cs +++ b/src/Lumina.Application/Core/MediaLibrary/Management/Commands/AddLibrary/AddLibraryCommand.cs @@ -20,6 +20,6 @@ namespace Lumina.Application.Core.MediaLibrary.Management.Commands.AddLibrary; public record AddLibraryCommand( Guid UserId, string? Title, - LibraryType? LibraryType, + string? LibraryType, string[]? ContentLocations ) : IRequest>; diff --git a/src/Lumina.Application/Core/MediaLibrary/Management/Commands/AddLibrary/AddLibraryCommandHandler.cs b/src/Lumina.Application/Core/MediaLibrary/Management/Commands/AddLibrary/AddLibraryCommandHandler.cs index 1e51e519..8d5d925e 100644 --- a/src/Lumina.Application/Core/MediaLibrary/Management/Commands/AddLibrary/AddLibraryCommandHandler.cs +++ b/src/Lumina.Application/Core/MediaLibrary/Management/Commands/AddLibrary/AddLibraryCommandHandler.cs @@ -1,13 +1,15 @@ #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.Errors; using Lumina.Application.Common.Mapping.MediaLibrary.Management; -using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management; -using Lumina.Domain.Common.Enums.MediaLibrary; using Lumina.Contracts.Responses.MediaLibrary.Management; +using Lumina.Domain.Common.Enums.MediaLibrary; using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate; using Mediator; +using System; using System.Threading; using System.Threading.Tasks; #endregion @@ -40,23 +42,31 @@ public class AddLibraryCommandHandler : IRequestHandler public async ValueTask> Handle(AddLibraryCommand request, CancellationToken cancellationToken) { + // create a domain library object ErrorOr createLibraryResult = Library.Create( request.UserId, request.Title!, - request.LibraryType ?? LibraryType.Other, + Enum.Parse(request.LibraryType!), request.ContentLocations! ); if (createLibraryResult.IsError) return createLibraryResult.Errors; - + // get a library repository ILibraryRepository libraryRepository = _unitOfWork.GetRepository(); + // convert the domain library entity to a repository library entity LibraryEntity persistenceLibrary = createLibraryResult.Value.ToRepositoryEntity(); + // insert the repository entity and save changes ErrorOr insertLibraryResult = await libraryRepository.InsertAsync(persistenceLibrary, cancellationToken).ConfigureAwait(false); if (insertLibraryResult.IsError) return insertLibraryResult.Errors; await _unitOfWork.SaveChangesAsync(cancellationToken).ConfigureAwait(false); - - return persistenceLibrary.ToResponse(); + // retrieve the newly saved media library from the persistence medium and return it + ErrorOr retrievedLibraryResult = await libraryRepository.GetByIdAsync(createLibraryResult.Value.Id.Value, cancellationToken).ConfigureAwait(false); + if (retrievedLibraryResult.IsError) + return retrievedLibraryResult.Errors; + if (retrievedLibraryResult.Value is null) + return Errors.Persistence.ErrorPersistingMediaLibrary; + return retrievedLibraryResult.Value.ToResponse(); } } diff --git a/src/Lumina.Application/Core/MediaLibrary/Management/Commands/AddLibrary/AddLibraryCommandValidator.cs b/src/Lumina.Application/Core/MediaLibrary/Management/Commands/AddLibrary/AddLibraryCommandValidator.cs index 4d7d88a8..ec6e1c14 100644 --- a/src/Lumina.Application/Core/MediaLibrary/Management/Commands/AddLibrary/AddLibraryCommandValidator.cs +++ b/src/Lumina.Application/Core/MediaLibrary/Management/Commands/AddLibrary/AddLibraryCommandValidator.cs @@ -1,5 +1,6 @@ #region ========================================================================= USING ===================================================================================== using FluentValidation; +using Lumina.Domain.Common.Enums.MediaLibrary; using Lumina.Domain.Common.Errors; using System; #endregion @@ -22,7 +23,8 @@ public class AddLibraryCommandValidator : AbstractValidator RuleFor(x => x.LibraryType) .NotNull().WithMessage(Errors.Library.LibraryTypeCannotBeNull.Description) - .IsInEnum().WithMessage(Errors.Library.UnknownLibraryType.Description); + .Must(x => Enum.TryParse(x, out _)) + .WithMessage(Errors.Library.UnknownLibraryType.Description); RuleFor(x => x.ContentLocations) .NotNull().WithMessage(Errors.Library.PathsListCannotBeNull.Description) diff --git a/src/Lumina.Application/Core/MediaLibrary/Management/Commands/UpdateLibrary/UpdateLibraryCommand.cs b/src/Lumina.Application/Core/MediaLibrary/Management/Commands/UpdateLibrary/UpdateLibraryCommand.cs new file mode 100644 index 00000000..530d8b68 --- /dev/null +++ b/src/Lumina.Application/Core/MediaLibrary/Management/Commands/UpdateLibrary/UpdateLibraryCommand.cs @@ -0,0 +1,29 @@ +#region ========================================================================= USING ===================================================================================== +using ErrorOr; +using Lumina.Domain.Common.Enums.MediaLibrary; +using Lumina.Contracts.Responses.MediaLibrary.Management; +using Mediator; +using System; +using System.Diagnostics; +#endregion + +namespace Lumina.Application.Core.MediaLibrary.Management.Commands.UpdateLibrary; + +/// +/// Command for updating a media library. +/// +/// The Id of the media library. +/// The Id of the user owning the media library. +/// The Id of the user making the request to update the media library. +/// The type of the media library. +/// The file system paths of the directories where the media library elements are located. +/// The title of the media library. +[DebuggerDisplay("Title: {Title}")] +public record UpdateLibraryCommand( + Guid Id, + Guid OwnerId, + Guid CurrentUserId, + string? Title, + string? LibraryType, + string[]? ContentLocations +) : IRequest>; diff --git a/src/Lumina.Application/Core/MediaLibrary/Management/Commands/UpdateLibrary/UpdateLibraryCommandHandler.cs b/src/Lumina.Application/Core/MediaLibrary/Management/Commands/UpdateLibrary/UpdateLibraryCommandHandler.cs new file mode 100644 index 00000000..7a95de4c --- /dev/null +++ b/src/Lumina.Application/Core/MediaLibrary/Management/Commands/UpdateLibrary/UpdateLibraryCommandHandler.cs @@ -0,0 +1,85 @@ +#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.Mapping.MediaLibrary.Management; +using Lumina.Contracts.Responses.MediaLibrary.Management; +using Lumina.Domain.Common.Enums.MediaLibrary; +using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate; +using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects; +using Mediator; +using System; +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.UpdateLibrary; + +/// +/// Handler for the command to update a media library. +/// +public class UpdateLibraryCommandHandler : IRequestHandler> +{ + private readonly IUnitOfWork _unitOfWork; + + /// + /// Initializes a new instance of the class. + /// + /// Injected unit of work for interacting with the data access layer repositories. + public UpdateLibraryCommandHandler(IUnitOfWork unitOfWork) + { + _unitOfWork = unitOfWork; + } + + /// + /// Handles the command to update a media library. + /// + /// The request to be handled. + /// Cancellation token that can be used to stop the execution. + /// + /// An containing either a successfully updated , or an error message. + /// + public async ValueTask> Handle(UpdateLibraryCommand request, CancellationToken cancellationToken) + { + // get a library repository + ILibraryRepository libraryRepository = _unitOfWork.GetRepository(); + ErrorOr resultGetLibrary = await libraryRepository.GetByIdAsync(request.Id, cancellationToken).ConfigureAwait(false); + if (resultGetLibrary.IsError) + return resultGetLibrary.Errors; + else if (resultGetLibrary.Value is null) + return DomainErrors.Library.LibraryNotFound; + // if the user that made the request is not an Admin or is not the owner of the library, they do not have the right to update it + if (resultGetLibrary.Value.UserId != request.CurrentUserId) // TODO: after implementing the Admin role, add that permission check here too + return ApplicationErrors.Authorization.NotAuthorized; + + // create a domain library object + ErrorOr createLibraryResult = Library.Create( + LibraryId.Create(request.Id), + request.OwnerId, + request.Title!, + Enum.Parse(request.LibraryType!), + request.ContentLocations! + ); + if (createLibraryResult.IsError) + return createLibraryResult.Errors; + // convert the domain library entity to a repository library entity + LibraryEntity persistenceLibrary = createLibraryResult.Value.ToRepositoryEntity(); + + // update the repository entity and save changes + ErrorOr updateLibraryResult = await libraryRepository.UpdateAsync(persistenceLibrary, cancellationToken).ConfigureAwait(false); + if (updateLibraryResult.IsError) + return updateLibraryResult.Errors; + await _unitOfWork.SaveChangesAsync(cancellationToken).ConfigureAwait(false); + + // retrieve the updated media library from the persistence medium and return it + ErrorOr retrievedLibraryResult = await libraryRepository.GetByIdAsync(createLibraryResult.Value.Id.Value, cancellationToken).ConfigureAwait(false); + if (retrievedLibraryResult.IsError) + return retrievedLibraryResult.Errors; + if (retrievedLibraryResult.Value is null) + return ApplicationErrors.Persistence.ErrorPersistingMediaLibrary; + return retrievedLibraryResult.Value.ToResponse(); + } +} diff --git a/src/Lumina.Application/Core/MediaLibrary/Management/Commands/UpdateLibrary/UpdateLibraryCommandValidator.cs b/src/Lumina.Application/Core/MediaLibrary/Management/Commands/UpdateLibrary/UpdateLibraryCommandValidator.cs new file mode 100644 index 00000000..5c2811e7 --- /dev/null +++ b/src/Lumina.Application/Core/MediaLibrary/Management/Commands/UpdateLibrary/UpdateLibraryCommandValidator.cs @@ -0,0 +1,49 @@ +#region ========================================================================= USING ===================================================================================== +using FluentValidation; +using Lumina.Domain.Common.Enums.MediaLibrary; +using Lumina.Domain.Common.Errors; +using System; +#endregion + +namespace Lumina.Application.Core.MediaLibrary.Management.Commands.UpdateLibrary; + +/// +/// Validates the needed validation rules for . +/// +public class UpdateLibraryCommandValidator : AbstractValidator +{ + /// + /// Initializes a new instance of the class. + /// + public UpdateLibraryCommandValidator() + { + RuleFor(x => x.Id) + .NotEmpty().WithMessage(Errors.Library.LibraryIdCannotBeEmpty.Description) + .Must(id => id != Guid.Empty).WithMessage(Errors.Library.LibraryIdCannotBeEmpty.Description); + + RuleFor(x => x.CurrentUserId) + .NotEmpty().WithMessage(Errors.Library.UserIdCannotBeEmpty.Description) + .Must(id => id != Guid.Empty).WithMessage(Errors.Library.UserIdCannotBeEmpty.Description); + + RuleFor(x => x.OwnerId) + .NotEmpty().WithMessage(Errors.Library.UserIdCannotBeEmpty.Description) + .Must(id => id != Guid.Empty).WithMessage(Errors.Library.UserIdCannotBeEmpty.Description); + + RuleFor(x => x.LibraryType) + .NotNull().WithMessage(Errors.Library.LibraryTypeCannotBeNull.Description) + .Must(x => Enum.TryParse(x, out _)) + .WithMessage(Errors.Library.UnknownLibraryType.Description); + + RuleFor(x => x.ContentLocations) + .NotNull().WithMessage(Errors.Library.PathsListCannotBeNull.Description) + .NotEmpty().WithMessage(Errors.Library.PathsListCannotBeEmpty.Description); + + RuleForEach(x => x.ContentLocations) + .NotEmpty().WithMessage(Errors.FileSystemManagement.PathCannotBeEmpty.Description) + .MaximumLength(260).WithMessage(Errors.FileSystemManagement.PathMustBeMaximum260CharactersLong.Description); + + RuleFor(x => x.Title) + .NotEmpty().WithMessage(Errors.Library.TitleCannotBeEmpty.Description) + .MaximumLength(255).WithMessage(Errors.Library.TitleMustBeMaximum255CharactersLong.Description); + } +} diff --git a/src/Lumina.Application/Core/MediaLibrary/Management/Queries/GetLibraryQuery.cs b/src/Lumina.Application/Core/MediaLibrary/Management/Queries/GetLibraryQuery.cs new file mode 100644 index 00000000..b90037ee --- /dev/null +++ b/src/Lumina.Application/Core/MediaLibrary/Management/Queries/GetLibraryQuery.cs @@ -0,0 +1,20 @@ +#region ========================================================================= USING ===================================================================================== +using ErrorOr; +using Lumina.Contracts.Responses.MediaLibrary.Management; +using Mediator; +using System; +using System.Diagnostics; +#endregion + +namespace Lumina.Application.Core.MediaLibrary.Management.Queries; + +/// +/// Query for getting a media library by its Id. +/// +/// The Id of the media library to get. +/// The Id os the user requesting the media library. +[DebuggerDisplay("Path: {Path}")] +public record GetLibraryQuery( + Guid Id, + Guid UserId +) : IRequest>; diff --git a/src/Lumina.Application/Core/MediaLibrary/Management/Queries/GetLibraryQueryHandler.cs b/src/Lumina.Application/Core/MediaLibrary/Management/Queries/GetLibraryQueryHandler.cs new file mode 100644 index 00000000..6d73b28d --- /dev/null +++ b/src/Lumina.Application/Core/MediaLibrary/Management/Queries/GetLibraryQueryHandler.cs @@ -0,0 +1,55 @@ +#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.Mapping.MediaLibrary.Management; +using Lumina.Contracts.Responses.MediaLibrary.Management; +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.Queries; + +/// +/// Handler for the query to authenticate an account. +/// +public class GetLibraryQueryHandler : IRequestHandler> +{ + private readonly IUnitOfWork _unitOfWork; + + /// + /// Initializes a new instance of the class. + /// + /// Injected unit of work for interacting with the data access layer repositories. + public GetLibraryQueryHandler( + IUnitOfWork unitOfWork) + { + _unitOfWork = unitOfWork; + } + + /// + /// Handles the query to authenticate an account. + /// + /// The request to be handled. + /// Cancellation token that can be used to stop the execution. + /// + /// An containing either a successfully created , or an error message. + /// + public async ValueTask> Handle(GetLibraryQuery request, CancellationToken cancellationToken) + { + ILibraryRepository libraryRepository = _unitOfWork.GetRepository(); + ErrorOr resultGetLibrary = await libraryRepository.GetByIdAsync(request.Id, cancellationToken).ConfigureAwait(false); + if (resultGetLibrary.IsError) + return resultGetLibrary.Errors; + else if (resultGetLibrary.Value is null) + 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 (resultGetLibrary.Value.UserId != request.UserId) // TODO: after implementing the Admin role, add that permission check here too + return ApplicationErrors.Authorization.NotAuthorized; + return resultGetLibrary.Value.ToResponse(); + } +} diff --git a/src/Lumina.Application/Core/MediaLibrary/Management/Queries/GetLibraryQueryValidator.cs b/src/Lumina.Application/Core/MediaLibrary/Management/Queries/GetLibraryQueryValidator.cs new file mode 100644 index 00000000..c45913d0 --- /dev/null +++ b/src/Lumina.Application/Core/MediaLibrary/Management/Queries/GetLibraryQueryValidator.cs @@ -0,0 +1,27 @@ +#region ========================================================================= USING ===================================================================================== +using FluentValidation; +using Lumina.Domain.Common.Errors; +using System; +#endregion + +namespace Lumina.Application.Core.MediaLibrary.Management.Queries; + +/// +/// Validates the needed validation rules for . +/// +public class GetLibraryQueryValidator : AbstractValidator +{ + /// + /// Initializes a new instance of the class. + /// + public GetLibraryQueryValidator() + { + RuleFor(x => x.Id) + .NotEmpty().WithMessage(Errors.Library.LibraryIdCannotBeEmpty.Description) + .Must(id => id != Guid.Empty).WithMessage(Errors.Library.LibraryIdCannotBeEmpty.Description); + + RuleFor(x => x.UserId) + .NotEmpty().WithMessage(Errors.Library.UserIdCannotBeEmpty.Description) + .Must(id => id != Guid.Empty).WithMessage(Errors.Library.UserIdCannotBeEmpty.Description); + } +} diff --git a/src/Lumina.Application/Core/UsersManagement/Authentication/Commands/ChangePassword/ChangePasswordCommandHandler.cs b/src/Lumina.Application/Core/UsersManagement/Authentication/Commands/ChangePassword/ChangePasswordCommandHandler.cs index 79cd59df..c821c0c2 100644 --- a/src/Lumina.Application/Core/UsersManagement/Authentication/Commands/ChangePassword/ChangePasswordCommandHandler.cs +++ b/src/Lumina.Application/Core/UsersManagement/Authentication/Commands/ChangePassword/ChangePasswordCommandHandler.cs @@ -46,7 +46,7 @@ public class ChangePasswordCommandHandler : IRequestHandler> Handle(ChangePasswordCommand request, CancellationToken cancellationToken) { IUserRepository userRepository = _unitOfWork.GetRepository(); - ErrorOr resultSelectUser = await userRepository.GetByUsernameAsync(request.Username!, cancellationToken); + ErrorOr resultSelectUser = await userRepository.GetByUsernameAsync(request.Username!, cancellationToken).ConfigureAwait(false); if (resultSelectUser.IsError) return resultSelectUser.Errors; else if (resultSelectUser.Value is null) @@ -59,7 +59,7 @@ public class ChangePasswordCommandHandler : IRequestHandler resultUpdateUser = await userRepository.UpdateAsync(resultSelectUser.Value, cancellationToken); + ErrorOr resultUpdateUser = await userRepository.UpdateAsync(resultSelectUser.Value, cancellationToken).ConfigureAwait(false); if (resultUpdateUser.IsError) return resultUpdateUser.Errors; await _unitOfWork.SaveChangesAsync(cancellationToken).ConfigureAwait(false); diff --git a/src/Lumina.Application/Core/UsersManagement/Authentication/Commands/RecoverPassword/RecoverPasswordCommandHandler.cs b/src/Lumina.Application/Core/UsersManagement/Authentication/Commands/RecoverPassword/RecoverPasswordCommandHandler.cs index 6030c904..93622228 100644 --- a/src/Lumina.Application/Core/UsersManagement/Authentication/Commands/RecoverPassword/RecoverPasswordCommandHandler.cs +++ b/src/Lumina.Application/Core/UsersManagement/Authentication/Commands/RecoverPassword/RecoverPasswordCommandHandler.cs @@ -56,7 +56,7 @@ public class RecoverPasswordCommandHandler : IRequestHandler(); - ErrorOr resultSelectUser = await userRepository.GetByUsernameAsync(request.Username!, cancellationToken); + ErrorOr resultSelectUser = await userRepository.GetByUsernameAsync(request.Username!, cancellationToken).ConfigureAwait(false); if (resultSelectUser.IsError) return resultSelectUser.Errors; else if (resultSelectUser.Value is null) @@ -76,7 +76,7 @@ public class RecoverPasswordCommandHandler : IRequestHandler resultUpdateUser = await userRepository.UpdateAsync(resultSelectUser.Value, cancellationToken); + ErrorOr resultUpdateUser = await userRepository.UpdateAsync(resultSelectUser.Value, cancellationToken).ConfigureAwait(false); if (resultUpdateUser.IsError) return resultUpdateUser.Errors; await _unitOfWork.SaveChangesAsync(cancellationToken).ConfigureAwait(false); diff --git a/src/Lumina.Application/Core/UsersManagement/Authentication/Commands/RegisterUser/RegisterUserCommandHandler.cs b/src/Lumina.Application/Core/UsersManagement/Authentication/Commands/RegisterUser/RegisterUserCommandHandler.cs index 9db2c4c4..248e6d00 100644 --- a/src/Lumina.Application/Core/UsersManagement/Authentication/Commands/RegisterUser/RegisterUserCommandHandler.cs +++ b/src/Lumina.Application/Core/UsersManagement/Authentication/Commands/RegisterUser/RegisterUserCommandHandler.cs @@ -60,7 +60,7 @@ public class RegisterUserCommandHandler : IRequestHandler(); - ErrorOr resultSelectUser = await userRepository.GetByUsernameAsync(request.Username!, cancellationToken); + ErrorOr resultSelectUser = await userRepository.GetByUsernameAsync(request.Username!, cancellationToken).ConfigureAwait(false); if (resultSelectUser.IsError) return resultSelectUser.Errors; else if (resultSelectUser.Value is not null) @@ -85,7 +85,7 @@ public class RegisterUserCommandHandler : IRequestHandler resultInsertUser = await userRepository.InsertAsync(user, cancellationToken); + ErrorOr resultInsertUser = await userRepository.InsertAsync(user, cancellationToken).ConfigureAwait(false); if (resultInsertUser.IsError) return resultInsertUser.Errors; await _unitOfWork.SaveChangesAsync(cancellationToken).ConfigureAwait(false); diff --git a/src/Lumina.Application/Core/UsersManagement/Authentication/Queries/LoginUser/LoginUserQueryHandler.cs b/src/Lumina.Application/Core/UsersManagement/Authentication/Queries/LoginUser/LoginUserQueryHandler.cs index 5ea0c600..606c9918 100644 --- a/src/Lumina.Application/Core/UsersManagement/Authentication/Queries/LoginUser/LoginUserQueryHandler.cs +++ b/src/Lumina.Application/Core/UsersManagement/Authentication/Queries/LoginUser/LoginUserQueryHandler.cs @@ -60,7 +60,7 @@ public class LoginUserQueryHandler : IRequestHandler(); - ErrorOr resultSelectUser = await userRepository.GetByUsernameAsync(request.Username!, cancellationToken); + ErrorOr resultSelectUser = await userRepository.GetByUsernameAsync(request.Username!, cancellationToken).ConfigureAwait(false); if (resultSelectUser.IsError) return resultSelectUser.Errors; else if (resultSelectUser.Value is null) diff --git a/src/Lumina.Contracts/Requests/MediaLibrary/Management/AddLibraryRequest.cs b/src/Lumina.Contracts/Requests/MediaLibrary/Management/AddLibraryRequest.cs index 44f19d22..6865ccf8 100644 --- a/src/Lumina.Contracts/Requests/MediaLibrary/Management/AddLibraryRequest.cs +++ b/src/Lumina.Contracts/Requests/MediaLibrary/Management/AddLibraryRequest.cs @@ -1,6 +1,4 @@ #region ========================================================================= USING ===================================================================================== -using Lumina.Domain.Common.Enums.MediaLibrary; -using System; using System.Diagnostics; #endregion @@ -15,6 +13,6 @@ namespace Lumina.Contracts.Requests.MediaLibrary.Management; [DebuggerDisplay("Title: {Title}")] public record AddLibraryRequest( string? Title, - LibraryType? LibraryType, + string? LibraryType, string[]? ContentLocations ); diff --git a/src/Lumina.Contracts/Requests/MediaLibrary/Management/GetLibraryRequest.cs b/src/Lumina.Contracts/Requests/MediaLibrary/Management/GetLibraryRequest.cs new file mode 100644 index 00000000..df1aaefc --- /dev/null +++ b/src/Lumina.Contracts/Requests/MediaLibrary/Management/GetLibraryRequest.cs @@ -0,0 +1,15 @@ +#region ========================================================================= USING ===================================================================================== +using System; +using System.Diagnostics; +#endregion + +namespace Lumina.Contracts.Requests.MediaLibrary.Management; + +/// +/// Represents a request to get a media library by its Id. +/// +/// The Id of the media library. Required. +[DebuggerDisplay("Id: {Id}")] +public record GetLibraryRequest( + Guid Id +); diff --git a/src/Lumina.Contracts/Requests/MediaLibrary/Management/UpdateLibraryRequest.cs b/src/Lumina.Contracts/Requests/MediaLibrary/Management/UpdateLibraryRequest.cs new file mode 100644 index 00000000..9f2dafbc --- /dev/null +++ b/src/Lumina.Contracts/Requests/MediaLibrary/Management/UpdateLibraryRequest.cs @@ -0,0 +1,24 @@ +#region ========================================================================= USING ===================================================================================== +using Lumina.Domain.Common.Enums.MediaLibrary; +using System; +using System.Diagnostics; +#endregion + +namespace Lumina.Contracts.Requests.MediaLibrary.Management; + +/// +/// Represents a request to update a media library. +/// +/// The Id of the media library. Required. +/// The Id of the user owning the media library. Required. +/// The title of the media library. Required. +/// The type of the media library. Required. +/// The file system paths of the directories where the media library elements are located. Required. +[DebuggerDisplay("Title: {Title}")] +public record class UpdateLibraryRequest( + Guid Id, + Guid UserId, + string? Title, + string? LibraryType, + string[]? ContentLocations +); diff --git a/src/Lumina.DataAccess/Core/Repositories/Libraries/LibraryRepository.cs b/src/Lumina.DataAccess/Core/Repositories/Libraries/LibraryRepository.cs index 08e5f75c..e060a9f4 100644 --- a/src/Lumina.DataAccess/Core/Repositories/Libraries/LibraryRepository.cs +++ b/src/Lumina.DataAccess/Core/Repositories/Libraries/LibraryRepository.cs @@ -1,10 +1,11 @@ #region ========================================================================= USING ===================================================================================== using ErrorOr; -using Lumina.Application.Common.DataAccess.Repositories.MediaLibrary; using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management; +using Lumina.Application.Common.DataAccess.Repositories.MediaLibrary; using Lumina.DataAccess.Core.UoW; using Lumina.Domain.Common.Errors; using Microsoft.EntityFrameworkCore; +using System; using System.Threading; using System.Threading.Tasks; #endregion @@ -42,4 +43,39 @@ internal sealed class LibraryRepository : ILibraryRepository _luminaDbContext.Libraries.Add(library); return Result.Created; } + + /// + /// Gets a identified by from the storage medium. + /// + /// The id of the library to get. + /// Cancellation token that can be used to stop the execution. + /// An containing either a identified by , or an error. + public async Task> GetByIdAsync(Guid id, CancellationToken cancellationToken) + { + return await _luminaDbContext.Libraries + .Include(library => library.ContentLocations) + .FirstOrDefaultAsync(library => library.Id == id, cancellationToken).ConfigureAwait(false); + } + + /// + /// Updates a media library. + /// + /// Ther media library to update. + /// Cancellation token that can be used to stop the execution. + /// An representing either a successfull operation, or an error. + public async Task> UpdateAsync(LibraryEntity data, CancellationToken cancellationToken) + { + LibraryEntity? foundLibrary = await _luminaDbContext.Libraries + .Include(library => library.ContentLocations) + .FirstOrDefaultAsync(library => library.Id == data.Id, cancellationToken).ConfigureAwait(false); + if (foundLibrary is null) + return Errors.Library.LibraryNotFound; + // update scalar properties + _luminaDbContext.Entry(foundLibrary).CurrentValues.SetValues(data); + // update owned entities (their changes are not automatically tracked by EF) + foundLibrary.ContentLocations.Clear(); + foreach (LibraryContentLocationEntity contentLocation in data.ContentLocations) + foundLibrary.ContentLocations.Add(contentLocation); + return Result.Updated; + } } diff --git a/src/Lumina.Domain/Common/Errors/Errors.Library.cs b/src/Lumina.Domain/Common/Errors/Errors.Library.cs index 94b991ba..aa97b3d1 100644 --- a/src/Lumina.Domain/Common/Errors/Errors.Library.cs +++ b/src/Lumina.Domain/Common/Errors/Errors.Library.cs @@ -11,8 +11,10 @@ public static partial class Errors { public static class Library { + public static Error LibraryIdCannotBeEmpty => Error.Forbidden(description: nameof(LibraryIdCannotBeEmpty)); public static Error UserIdCannotBeEmpty => Error.Forbidden(description: nameof(UserIdCannotBeEmpty)); public static Error LibraryAlreadyExists => Error.Conflict(description: nameof(LibraryAlreadyExists)); + public static Error LibraryNotFound => Error.NotFound(description: nameof(LibraryNotFound)); public static Error LibraryTypeCannotBeNull => Error.Validation(description: nameof(LibraryTypeCannotBeNull)); public static Error UnknownLibraryType => Error.Unexpected(description: nameof(UnknownLibraryType)); public static Error PathsListCannotBeNull => Error.Validation(description: nameof(PathsListCannotBeNull)); diff --git a/src/Lumina.Presentation.Api/Common/Routes/Library/Management/ApiRoutes.Libraries.cs b/src/Lumina.Presentation.Api/Common/Routes/Library/Management/ApiRoutes.Libraries.cs index c1c20675..bb67db20 100644 --- a/src/Lumina.Presentation.Api/Common/Routes/Library/Management/ApiRoutes.Libraries.cs +++ b/src/Lumina.Presentation.Api/Common/Routes/Library/Management/ApiRoutes.Libraries.cs @@ -13,5 +13,6 @@ public static partial class ApiRoutes public const string GET_LIBRARY_BY_ID = "/libraries/{id}"; public const string GET_LIBRARIES = "/libraries"; public const string ADD_LIBRARY = "/libraries"; + public const string UPDATE_LIBRARY = "/libraries/{id}"; } } diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Directories/GetDirectories/GetDirectoriesEndpointSummary.cs b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Directories/GetDirectories/GetDirectoriesEndpointSummary.cs index 0d9f4ae4..145dcf37 100644 --- a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Directories/GetDirectories/GetDirectoriesEndpointSummary.cs +++ b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Directories/GetDirectories/GetDirectoriesEndpointSummary.cs @@ -10,7 +10,7 @@ using System.Diagnostics.CodeAnalysis; namespace Lumina.Presentation.Api.Core.Endpoints.FileSystemManagement.Directories.GetDirectories; /// -/// Class used for providing a textual description for the API endpoint, for Swagger. +/// Class used for providing a textual description for the API endpoint, for OpenAPI. /// [ExcludeFromCodeCoverage] public class GetDirectoriesEndpointSummary : Summary diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Directories/GetDirectoryTree/GetDirectoryTreeEndpointSummary.cs b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Directories/GetDirectoryTree/GetDirectoryTreeEndpointSummary.cs index 3907f11d..f47ca07b 100644 --- a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Directories/GetDirectoryTree/GetDirectoryTreeEndpointSummary.cs +++ b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Directories/GetDirectoryTree/GetDirectoryTreeEndpointSummary.cs @@ -10,7 +10,7 @@ using System.Diagnostics.CodeAnalysis; namespace Lumina.Presentation.Api.Core.Endpoints.FileSystemManagement.Directories.GetDirectoryTree; /// -/// Class used for providing a textual description for the API endpoint, for Swagger. +/// Class used for providing a textual description for the API endpoint, for OpenAPI. /// [ExcludeFromCodeCoverage] public class GetDirectoryTreeEndpointSummary : Summary diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Directories/GetTreeDirectories/GetTreeDirectoriesEndpointSummary.cs b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Directories/GetTreeDirectories/GetTreeDirectoriesEndpointSummary.cs index 60417a9a..a5cb1344 100644 --- a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Directories/GetTreeDirectories/GetTreeDirectoriesEndpointSummary.cs +++ b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Directories/GetTreeDirectories/GetTreeDirectoriesEndpointSummary.cs @@ -10,7 +10,7 @@ using System.Diagnostics.CodeAnalysis; namespace Lumina.Presentation.Api.Core.Endpoints.FileSystemManagement.Directories.GetTreeDirectories; /// -/// Class used for providing a textual description for the API endpoint, for Swagger. +/// Class used for providing a textual description for the API endpoint, for OpenAPI. /// [ExcludeFromCodeCoverage] public class GetTreeDirectoriesEndpointSummary : Summary diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Drives/GetDrives/GetDrivesEndpointSummary.cs b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Drives/GetDrives/GetDrivesEndpointSummary.cs index 2e3f4563..dff2151a 100644 --- a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Drives/GetDrives/GetDrivesEndpointSummary.cs +++ b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Drives/GetDrives/GetDrivesEndpointSummary.cs @@ -9,7 +9,7 @@ using System.Diagnostics.CodeAnalysis; namespace Lumina.Presentation.Api.Core.Endpoints.FileSystemManagement.Drives.GetDrives; /// -/// Class used for providing a textual description for the API endpoint, for Swagger. +/// Class used for providing a textual description for the API endpoint, for OpenAPI. /// [ExcludeFromCodeCoverage] public class GetDrivesEndpointSummary : Summary diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/FileSystem/GetType/GetTypeEndpointSummary.cs b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/FileSystem/GetType/GetTypeEndpointSummary.cs index e241deaa..4f7d5f0a 100644 --- a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/FileSystem/GetType/GetTypeEndpointSummary.cs +++ b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/FileSystem/GetType/GetTypeEndpointSummary.cs @@ -8,7 +8,7 @@ using System.Diagnostics.CodeAnalysis; namespace Lumina.Presentation.Api.Core.Endpoints.FileSystemManagement.FileSystem.GetType; /// -/// Class used for providing a textual description for the API endpoint, for Swagger. +/// Class used for providing a textual description for the API endpoint, for OpenAPI. /// [ExcludeFromCodeCoverage] public class GetTypeEndpointSummary : Summary diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Files/GetFiles/GetFilesEndpointSummary.cs b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Files/GetFiles/GetFilesEndpointSummary.cs index e45bcf27..690e8ac2 100644 --- a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Files/GetFiles/GetFilesEndpointSummary.cs +++ b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Files/GetFiles/GetFilesEndpointSummary.cs @@ -11,7 +11,7 @@ using System.Diagnostics.CodeAnalysis; namespace Lumina.Presentation.Api.Core.Endpoints.FileSystemManagement.Files.GetFiles; /// -/// Class used for providing a textual description for the API endpoint, for Swagger. +/// Class used for providing a textual description for the API endpoint, for OpenAPI. /// [ExcludeFromCodeCoverage] public class GetFilesEndpointSummary : Summary diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Files/GetTreeFiles/GetTreeFilesEndpointSummary.cs b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Files/GetTreeFiles/GetTreeFilesEndpointSummary.cs index 03e37673..ae47edf9 100644 --- a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Files/GetTreeFiles/GetTreeFilesEndpointSummary.cs +++ b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Files/GetTreeFiles/GetTreeFilesEndpointSummary.cs @@ -10,7 +10,7 @@ using System.Diagnostics.CodeAnalysis; namespace Lumina.Presentation.Api.Core.Endpoints.FileSystemManagement.Files.GetTreeFiles; /// -/// Class used for providing a textual description for the API endpoint, for Swagger. +/// Class used for providing a textual description for the API endpoint, for OpenAPI. /// [ExcludeFromCodeCoverage] public class GetTreeFilesEndpointSummary : Summary diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/CheckPathExists/CheckPathExistsEndpointSummary.cs b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/CheckPathExists/CheckPathExistsEndpointSummary.cs index 7968ab0b..654abe25 100644 --- a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/CheckPathExists/CheckPathExistsEndpointSummary.cs +++ b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/CheckPathExists/CheckPathExistsEndpointSummary.cs @@ -10,7 +10,7 @@ using System.Diagnostics.CodeAnalysis; namespace Lumina.Presentation.Api.Core.Endpoints.FileSystemManagement.Path.CheckPathExists; /// -/// Class used for providing a textual description for the API endpoint, for Swagger. +/// Class used for providing a textual description for the API endpoint, for OpenAPI. /// [ExcludeFromCodeCoverage] public class CheckPathExistsEndpointSummary : Summary diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/CombinePath/CombinePathEndpointSummary.cs b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/CombinePath/CombinePathEndpointSummary.cs index da4bf4dc..1a494569 100644 --- a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/CombinePath/CombinePathEndpointSummary.cs +++ b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/CombinePath/CombinePathEndpointSummary.cs @@ -9,7 +9,7 @@ using System.Diagnostics.CodeAnalysis; namespace Lumina.Presentation.Api.Core.Endpoints.FileSystemManagement.Path.CombinePath; /// -/// Class used for providing a textual description for the API endpoint, for Swagger. +/// Class used for providing a textual description for the API endpoint, for OpenAPI. /// [ExcludeFromCodeCoverage] public class CombinePathEndpointSummary : Summary diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/GetPathParent/GetPathParentEndpointSummary.cs b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/GetPathParent/GetPathParentEndpointSummary.cs index a8c4bb31..5c749a4f 100644 --- a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/GetPathParent/GetPathParentEndpointSummary.cs +++ b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/GetPathParent/GetPathParentEndpointSummary.cs @@ -9,7 +9,7 @@ using System.Diagnostics.CodeAnalysis; namespace Lumina.Presentation.Api.Core.Endpoints.FileSystemManagement.Path.GetPathParent; /// -/// Class used for providing a textual description for the API endpoint, for Swagger. +/// Class used for providing a textual description for the API endpoint, for OpenAPI. /// [ExcludeFromCodeCoverage] public class GetPathParentEndpointSummary : Summary diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/GetPathRoot/GetPathRootEndpointSummary.cs b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/GetPathRoot/GetPathRootEndpointSummary.cs index 4f633984..5dc4edb2 100644 --- a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/GetPathRoot/GetPathRootEndpointSummary.cs +++ b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/GetPathRoot/GetPathRootEndpointSummary.cs @@ -9,7 +9,7 @@ using System.Diagnostics.CodeAnalysis; namespace Lumina.Presentation.Api.Core.Endpoints.FileSystemManagement.Path.GetPathRoot; /// -/// Class used for providing a textual description for the API endpoint, for Swagger. +/// Class used for providing a textual description for the API endpoint, for OpenAPI. /// [ExcludeFromCodeCoverage] public class GetPathRootEndpointSummary : Summary diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/GetPathSeparator/GetPathSeparatorEndpointSummary.cs b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/GetPathSeparator/GetPathSeparatorEndpointSummary.cs index 3945e9d4..d2321cb0 100644 --- a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/GetPathSeparator/GetPathSeparatorEndpointSummary.cs +++ b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/GetPathSeparator/GetPathSeparatorEndpointSummary.cs @@ -7,7 +7,7 @@ using System.Diagnostics.CodeAnalysis; namespace Lumina.Presentation.Api.Core.Endpoints.FileSystemManagement.Path.GetPathSeparator; /// -/// Class used for providing a textual description for the API endpoint, for Swagger. +/// Class used for providing a textual description for the API endpoint, for OpenAPI. /// [ExcludeFromCodeCoverage] public class GetPathSeparatorEndpointSummary : Summary diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/SplitPath/SplitPathEndpointSummary.cs b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/SplitPath/SplitPathEndpointSummary.cs index 7b9f808d..21e6a5fb 100644 --- a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/SplitPath/SplitPathEndpointSummary.cs +++ b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/SplitPath/SplitPathEndpointSummary.cs @@ -9,7 +9,7 @@ using System.Diagnostics.CodeAnalysis; namespace Lumina.Presentation.Api.Core.Endpoints.FileSystemManagement.Path.SplitPath; /// -/// Class used for providing a textual description for the API endpoint, for Swagger. +/// Class used for providing a textual description for the API endpoint, for OpenAPI. /// [ExcludeFromCodeCoverage] public class SplitPathEndpointSummary : Summary diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/ValidatePath/ValidatePathEndpointSummary.cs b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/ValidatePath/ValidatePathEndpointSummary.cs index e2193df8..fe387cd4 100644 --- a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/ValidatePath/ValidatePathEndpointSummary.cs +++ b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Path/ValidatePath/ValidatePathEndpointSummary.cs @@ -9,7 +9,7 @@ using System.Diagnostics.CodeAnalysis; namespace Lumina.Presentation.Api.Core.Endpoints.FileSystemManagement.Path.ValidatePath; /// -/// Class used for providing a textual description for the API endpoint, for Swagger. +/// Class used for providing a textual description for the API endpoint, for OpenAPI. /// [ExcludeFromCodeCoverage] public class ValidatePathEndpointSummary : Summary diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Thumbnails/GetThumbnail/GetThumbnailEndpointSummary.cs b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Thumbnails/GetThumbnail/GetThumbnailEndpointSummary.cs index 83d9ac26..9417c0fc 100644 --- a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Thumbnails/GetThumbnail/GetThumbnailEndpointSummary.cs +++ b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Thumbnails/GetThumbnail/GetThumbnailEndpointSummary.cs @@ -8,7 +8,7 @@ using System.Diagnostics.CodeAnalysis; namespace Lumina.Presentation.Api.Core.Endpoints.FileSystemManagement.Thumbnails.GetThumbnail; /// -/// Class used for providing a textual description for the API endpoint, for Swagger. +/// Class used for providing a textual description for the API endpoint, for OpenAPI. /// [ExcludeFromCodeCoverage] public class GetThumbnailEndpointSummary : Summary diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/Library/Management/AddLibrary/AddLibraryEndpoint.cs b/src/Lumina.Presentation.Api/Core/Endpoints/Library/Management/AddLibrary/AddLibraryEndpoint.cs index 4346bdc3..3c2be24b 100644 --- a/src/Lumina.Presentation.Api/Core/Endpoints/Library/Management/AddLibrary/AddLibraryEndpoint.cs +++ b/src/Lumina.Presentation.Api/Core/Endpoints/Library/Management/AddLibrary/AddLibraryEndpoint.cs @@ -50,6 +50,7 @@ public class AddLibraryEndpoint : BaseEndpoint /// Cancellation token that can be used to stop the execution. public override async Task ExecuteAsync(AddLibraryRequest request, CancellationToken cancellationToken) { + // retrieve the currently authenticated user, and send it with the request string? user = User.FindFirstValue(ClaimTypes.NameIdentifier); ErrorOr result = await _sender.Send(request.ToCommand(Guid.Parse(user!)), cancellationToken).ConfigureAwait(false); return result.Match(success => TypedResults.Created($"{BaseURL}api/v1{ApiRoutes.Libraries.ADD_LIBRARY}/{result.Value.Id}", result.Value), Problem); diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/Library/Management/AddLibrary/AddLibraryEndpointSummary.cs b/src/Lumina.Presentation.Api/Core/Endpoints/Library/Management/AddLibrary/AddLibraryEndpointSummary.cs index 1e9c9584..8d0bf41f 100644 --- a/src/Lumina.Presentation.Api/Core/Endpoints/Library/Management/AddLibrary/AddLibraryEndpointSummary.cs +++ b/src/Lumina.Presentation.Api/Core/Endpoints/Library/Management/AddLibrary/AddLibraryEndpointSummary.cs @@ -6,14 +6,12 @@ using Lumina.Domain.Common.Enums.MediaLibrary; using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; - - #endregion namespace Lumina.Presentation.Api.Core.Endpoints.Library.Management.AddLibrary; /// -/// Class used for providing a textual description for the API endpoint, for Swagger. +/// Class used for providing a textual description for the API endpoint, for OpenAPI. /// [ExcludeFromCodeCoverage] public class AddLibraryEndpointSummary : Summary @@ -28,7 +26,7 @@ public class AddLibraryEndpointSummary : Summary +/// API endpoint for the /libraries/{id} route. +/// +public class GetLibraryEndpoint : BaseEndpoint +{ + private readonly ISender _sender; + + /// + /// Initializes a new instance of the class. + /// + /// Injected service for mediating commands and queries. + public GetLibraryEndpoint(ISender sender) + { + _sender = sender; + } + + /// + /// Configures the API endpoint. + /// + public override void Configure() + { + Verbs(Http.GET); + Routes(ApiRoutes.Libraries.GET_LIBRARY_BY_ID); + Version(1); + DontCatchExceptions(); + } + + /// + /// Gets a library by Id. + /// + /// The request containing the id of the library to be retrieved. + /// Cancellation token that can be used to stop the execution. + public override async Task ExecuteAsync(GetLibraryRequest request, CancellationToken cancellationToken) + { + // retrieve the currently authenticated user, and send it with the request + string? user = User.FindFirstValue(ClaimTypes.NameIdentifier); + ErrorOr result = await _sender.Send(request.ToQuery(Guid.Parse(user!)), cancellationToken).ConfigureAwait(false); + return result.Match(success => TypedResults.Ok(success), Problem); + } +} diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/Library/Management/GetLibrary/GetLibraryEndpointSummary.cs b/src/Lumina.Presentation.Api/Core/Endpoints/Library/Management/GetLibrary/GetLibraryEndpointSummary.cs new file mode 100644 index 00000000..26388843 --- /dev/null +++ b/src/Lumina.Presentation.Api/Core/Endpoints/Library/Management/GetLibrary/GetLibraryEndpointSummary.cs @@ -0,0 +1,129 @@ +#region ========================================================================= USING ===================================================================================== +using FastEndpoints; +using Lumina.Contracts.Requests.MediaLibrary.Management; +using Lumina.Contracts.Responses.MediaLibrary.Management; +using Lumina.Domain.Common.Enums.MediaLibrary; +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +#endregion + +namespace Lumina.Presentation.Api.Core.Endpoints.Library.Management.GetLibrary; + +/// +/// Class used for providing a textual description for the API endpoint, for OpenAPI. +/// +[ExcludeFromCodeCoverage] +public class GetLibraryEndpointSummary : Summary +{ + /// + /// Initializes a new instance of the class. + /// + public GetLibraryEndpointSummary() + { + Summary = "Retrieves a media library by its Id."; + Description = "Retrieves a media library by its Id, if the user making the request is an Admin, or the owner of the library."; + + ExampleRequest = new GetLibraryRequest( + Id: Guid.NewGuid() + ); + + RequestParam(r => r.Id, "The Id of the media library. Required."); + + ResponseParam(r => r.Id, "The unique identifier of the entity."); + ResponseParam(r => r.UserId, "The Id of the user owning the media library."); + ResponseParam(r => r.Title, "The title of the media library."); + ResponseParam(r => r.LibraryType, "The type of the media library."); + ResponseParam(r => r.ContentLocations, "The file system paths of the directories where the media library elements are located."); + ResponseParam(r => r.Created, "The date and time when the entity was created."); + ResponseParam(r => r.Updated, "The date and time when the entity was last updated."); + + Response(200, "The media library is returned.", example: new LibraryResponse( + Id: Guid.NewGuid(), + UserId: Guid.NewGuid(), + Title: "TV Shows", + LibraryType: LibraryType.TvShow, + ContentLocations: ["/media/tv shows/drama/", "/media/tv shows/SCI-FI/"], + Created: DateTime.UtcNow, + Updated: 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/{id}" + }, + 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/{id}" + }, + new + { + type = "https://tools.ietf.org/html/rfc7235#section-3.1", + status = 401, + title = "Unauthorized", + detail = "The token is invalid", + instance = "/api/v1/libraries/{id}" + } + } + ); + + Response(403, "The request failed because the user making the request is not an Admin, or the owner of the media library.", "application/problem+json", + example: new + { + type = "https://tools.ietf.org/html/rfc9110#section-15.5.4", + title = "General.Failure", + status = 403, + detail = "NotAuthorized", + instance = "/api/v1/libraries/{id}", + traceId = "00-a712bbf99ca8ab485f86a762ae5ae74d-b3a2eb78813b0a5d-00" + } + ); + + Response(404, "The request failed because the requested media library does not exist.", "application/problem+json", + example: new + { + type = "https://tools.ietf.org/html/rfc9110#section-15.5.5", + title = "General.NotFound", + status = 404, + detail = "LibraryNotFound", + instance = "/api/v1/libraries/{id}", + traceId = "00-57d15dadd702dbd4aeb5dc9b7cee68ee-9330237dbb2ce0e5-00" + } + ); + + Response(422, "The request did not pass validation checks.", "application/problem+json", + example: new + { + type = "https://tools.ietf.org/html/rfc4918#section-11.2", + title = "General.Validation", + status = 422, + detail = "OneOrMoreValidationErrorsOccurred", + instance = "/api/v1/libraries/{id}", + errors = new Dictionary + { + { + "General.Validation", new[] + { + "UserIdCannotBeEmpty", + "LibraryIdCannotBeEmpty" + } + } + }, + traceId = "00-2470be4248a2a5a0c6f70579975a6954-b9c3ba9544a03500-00" + } + ); + + } +} diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/Library/Management/UpdateLibrary/UpdateLibraryEndpoint.cs b/src/Lumina.Presentation.Api/Core/Endpoints/Library/Management/UpdateLibrary/UpdateLibraryEndpoint.cs new file mode 100644 index 00000000..0e86ecd0 --- /dev/null +++ b/src/Lumina.Presentation.Api/Core/Endpoints/Library/Management/UpdateLibrary/UpdateLibraryEndpoint.cs @@ -0,0 +1,58 @@ +#region ========================================================================= USING ===================================================================================== +using ErrorOr; +using FastEndpoints; +using Lumina.Application.Common.Mapping.MediaLibrary.Management; +using Lumina.Contracts.Requests.MediaLibrary.Management; +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; +using System.Security.Claims; +using System.Threading; +using System.Threading.Tasks; +#endregion + +namespace Lumina.Presentation.Api.Core.Endpoints.Library.Management.UpdateLibrary; + +/// +/// API endpoint for the /libraries/{id} route. +/// +public class UpdateLibraryEndpoint : BaseEndpoint +{ + private readonly ISender _sender; + + /// + /// Initializes a new instance of the class. + /// + /// Injected service for mediating commands and queries. + public UpdateLibraryEndpoint(ISender sender) + { + _sender = sender; + } + + /// + /// Configures the API endpoint. + /// + public override void Configure() + { + Verbs(Http.PUT); + Routes(ApiRoutes.Libraries.UPDATE_LIBRARY); + Version(1); + DontCatchExceptions(); + } + + /// + /// Updates a media library stored in . + /// + /// The request containing the media library to be updated. + /// Cancellation token that can be used to stop the execution. + public override async Task ExecuteAsync(UpdateLibraryRequest request, CancellationToken cancellationToken) + { + // retrieve the currently authenticated user, and send it with the request + string? user = User.FindFirstValue(ClaimTypes.NameIdentifier); + ErrorOr result = await _sender.Send(request.ToCommand(Guid.Parse(user!)), cancellationToken).ConfigureAwait(false); + return result.Match(success => TypedResults.Ok(success), Problem); + } +} diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/Library/Management/UpdateLibrary/UpdateLibraryEndpointSummary.cs b/src/Lumina.Presentation.Api/Core/Endpoints/Library/Management/UpdateLibrary/UpdateLibraryEndpointSummary.cs new file mode 100644 index 00000000..621698e7 --- /dev/null +++ b/src/Lumina.Presentation.Api/Core/Endpoints/Library/Management/UpdateLibrary/UpdateLibraryEndpointSummary.cs @@ -0,0 +1,148 @@ +#region ========================================================================= USING ===================================================================================== +using FastEndpoints; +using Lumina.Contracts.Requests.MediaLibrary.Management; +using Lumina.Contracts.Responses.MediaLibrary.Management; +using Lumina.Domain.Common.Enums.MediaLibrary; +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +#endregion + +namespace Lumina.Presentation.Api.Core.Endpoints.Library.Management.UpdateLibrary; + +/// +/// Class used for providing a textual description for the API endpoint, for OpenAPI. +/// +[ExcludeFromCodeCoverage] +public class UpdateLibraryEndpointSummary : Summary +{ + /// + /// Initializes a new instance of the class. + /// + public UpdateLibraryEndpointSummary() + { + Summary = "Updates an existing media library."; + Description = "Updates a media library and returns its details, if the user making the request is an Admin, or the owner of the library."; + + ExampleRequest = new UpdateLibraryRequest( + Id: Guid.NewGuid(), + UserId: Guid.NewGuid(), + Title: "TV Shows", + LibraryType: "TvShow", + ContentLocations: [ + "/media/tv shows/drama/", + "/media/tv shows/SCI-FI/", + ] + ); + + RequestParam(r => r.Id, "The Id of the media library. Required."); + RequestParam(r => r.UserId, "The Id of the user owning the media library. Required."); + RequestParam(r => r.Title, "The title of the media library. Required."); + RequestParam(r => r.LibraryType, "The type of the media library. Required."); + RequestParam(r => r.ContentLocations, ">The file system paths of the directories where the media library elements are located. Required."); + + ResponseParam(r => r.Id, "The unique identifier of the entity."); + ResponseParam(r => r.UserId, "The Id of the user owning the media library."); + ResponseParam(r => r.Title, "The title of the media library."); + ResponseParam(r => r.LibraryType, "The type of the media library."); + ResponseParam(r => r.ContentLocations, "The file system paths of the directories where the media library elements are located."); + ResponseParam(r => r.Created, "The date and time when the entity was created."); + ResponseParam(r => r.Updated, "The date and time when the entity was last updated."); + + + Response(200, "The media library was successfully updated.", example: + new LibraryResponse( + Id: Guid.NewGuid(), + UserId: Guid.NewGuid(), + Title: "TV Shows", + LibraryType: LibraryType.TvShow, + ContentLocations: ["/media/tv shows/drama/", "/media/tv shows/SCI-FI/"], + Created: DateTime.UtcNow, + Updated: 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" + } + } + ); + + Response(403, "The request failed because the user making the request is not an Admin, or the owner of the media library.", "application/problem+json", + example: new + { + type = "https://tools.ietf.org/html/rfc9110#section-15.5.4", + title = "General.Failure", + status = 403, + detail = "NotAuthorized", + instance = "/api/v1/libraries/{id}", + traceId = "00-a712bbf99ca8ab485f86a762ae5ae74d-b3a2eb78813b0a5d-00" + } + ); + + Response(404, "The request failed because the requested media library does not exist.", "application/problem+json", + example: new + { + type = "https://tools.ietf.org/html/rfc9110#section-15.5.5", + title = "General.NotFound", + status = 404, + detail = "LibraryNotFound", + instance = "/api/v1/libraries/{id}", + traceId = "00-57d15dadd702dbd4aeb5dc9b7cee68ee-9330237dbb2ce0e5-00" + } + ); + + Response(422, "The request did not pass validation checks.", "application/problem+json", + example: new + { + type = "https://tools.ietf.org/html/rfc4918#section-11.2", + title = "General.Validation", + status = 422, + detail = "OneOrMoreValidationErrorsOccurred", + instance = "/api/v1/libraries", + errors = new Dictionary + { + { + "General.Validation", new[] + { + "UserIdCannotBeEmpty", + "LibraryTypeCannotBeNull", + "LibraryTypeCannotBeNull", + "UnknownLibraryType", + "PathsListCannotBeNull", + "PathsListCannotBeEmpty", + "PathCannotBeEmpty", + "TitleCannotBeEmpty", + "TitleMustBeMaximum255CharactersLong" + } + } + }, + traceId = "00-2470be4248a2a5a0c6f70579975a6954-b9c3ba9544a03500-00" + } + ); + } +} diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/Library/WrittenContentLibrary/BookLibrary/Books/AddBook/AddBookEndpointSummary.cs b/src/Lumina.Presentation.Api/Core/Endpoints/Library/WrittenContentLibrary/BookLibrary/Books/AddBook/AddBookEndpointSummary.cs index eb6f917d..5bc3c5b3 100644 --- a/src/Lumina.Presentation.Api/Core/Endpoints/Library/WrittenContentLibrary/BookLibrary/Books/AddBook/AddBookEndpointSummary.cs +++ b/src/Lumina.Presentation.Api/Core/Endpoints/Library/WrittenContentLibrary/BookLibrary/Books/AddBook/AddBookEndpointSummary.cs @@ -14,7 +14,7 @@ using System; namespace Lumina.Presentation.Api.Core.Endpoints.Library.WrittenContentLibrary.BookLibrary.Books.AddBook; /// -/// Class used for providing a textual description for the API endpoint, for Swagger. +/// Class used for providing a textual description for the API endpoint, for OpenAPI. /// [ExcludeFromCodeCoverage] public class AddLibraryEndpointSummary : Summary diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/Library/WrittenContentLibrary/BookLibrary/Books/GetBooks/GetBooksEndpointSummary.cs b/src/Lumina.Presentation.Api/Core/Endpoints/Library/WrittenContentLibrary/BookLibrary/Books/GetBooks/GetBooksEndpointSummary.cs index 718ee24a..22c3f7dd 100644 --- a/src/Lumina.Presentation.Api/Core/Endpoints/Library/WrittenContentLibrary/BookLibrary/Books/GetBooks/GetBooksEndpointSummary.cs +++ b/src/Lumina.Presentation.Api/Core/Endpoints/Library/WrittenContentLibrary/BookLibrary/Books/GetBooks/GetBooksEndpointSummary.cs @@ -13,7 +13,7 @@ using System.Diagnostics.CodeAnalysis; namespace Lumina.Presentation.Api.Core.Endpoints.Library.WrittenContentLibrary.BookLibrary.Books.GetBooks; /// -/// Class used for providing a textual description for the API endpoint, for Swagger. +/// Class used for providing a textual description for the API endpoint, for OpenAPI. /// [ExcludeFromCodeCoverage] public class GetBooksEndpointSummary : Summary diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/Library/WrittenContentLibrary/BookLibrary/GetBook/GetBookEndpoint.cs b/src/Lumina.Presentation.Api/Core/Endpoints/Library/WrittenContentLibrary/BookLibrary/GetBook/GetBookEndpoint.cs index 108d4ebd..1bec1041 100644 --- a/src/Lumina.Presentation.Api/Core/Endpoints/Library/WrittenContentLibrary/BookLibrary/GetBook/GetBookEndpoint.cs +++ b/src/Lumina.Presentation.Api/Core/Endpoints/Library/WrittenContentLibrary/BookLibrary/GetBook/GetBookEndpoint.cs @@ -12,7 +12,7 @@ using System.Threading.Tasks; namespace Lumina.Presentation.Api.Core.Endpoints.Library.WrittenContentLibrary.BookLibrary.GetBook; /// -/// API endpoint for the /books route. +/// API endpoint for the /books/{id} route. /// public class GetBookEndpoint : BaseEndpoint { diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/Maintenance/ApplicationSetup/CheckInitializationEndpointSummary.cs b/src/Lumina.Presentation.Api/Core/Endpoints/Maintenance/ApplicationSetup/CheckInitializationEndpointSummary.cs index 229b6ba1..db52a732 100644 --- a/src/Lumina.Presentation.Api/Core/Endpoints/Maintenance/ApplicationSetup/CheckInitializationEndpointSummary.cs +++ b/src/Lumina.Presentation.Api/Core/Endpoints/Maintenance/ApplicationSetup/CheckInitializationEndpointSummary.cs @@ -7,7 +7,7 @@ using System.Diagnostics.CodeAnalysis; namespace Lumina.Presentation.Api.Core.Endpoints.Maintenance.ApplicationSetup; /// -/// Class used for providing a textual description for the API endpoint, for Swagger. +/// Class used for providing a textual description for the API endpoint, for OpenAPI. /// [ExcludeFromCodeCoverage] public class CheckInitializationEndpointSummary : Summary diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/Maintenance/ApplicationSetup/SetupApplicationEndpointSummary.cs b/src/Lumina.Presentation.Api/Core/Endpoints/Maintenance/ApplicationSetup/SetupApplicationEndpointSummary.cs index 0f5307b7..c3ee6d0f 100644 --- a/src/Lumina.Presentation.Api/Core/Endpoints/Maintenance/ApplicationSetup/SetupApplicationEndpointSummary.cs +++ b/src/Lumina.Presentation.Api/Core/Endpoints/Maintenance/ApplicationSetup/SetupApplicationEndpointSummary.cs @@ -10,7 +10,7 @@ using System.Diagnostics.CodeAnalysis; namespace Lumina.Presentation.Api.Core.Endpoints.Maintenance.ApplicationSetup; /// -/// Class used for providing a textual description for the API endpoint, for Swagger. +/// Class used for providing a textual description for the API endpoint, for OpenAPI. /// [ExcludeFromCodeCoverage] public class SetupApplicationEndpointSummary : Summary diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/UsersManagement/Authentication/ChangePassword/ChangePasswordEndpointSummary.cs b/src/Lumina.Presentation.Api/Core/Endpoints/UsersManagement/Authentication/ChangePassword/ChangePasswordEndpointSummary.cs index 36bfa97a..f63eb8dc 100644 --- a/src/Lumina.Presentation.Api/Core/Endpoints/UsersManagement/Authentication/ChangePassword/ChangePasswordEndpointSummary.cs +++ b/src/Lumina.Presentation.Api/Core/Endpoints/UsersManagement/Authentication/ChangePassword/ChangePasswordEndpointSummary.cs @@ -9,7 +9,7 @@ using System.Diagnostics.CodeAnalysis; namespace Lumina.Presentation.Api.Core.Endpoints.UsersManagement.Authentication.ChangePassword; /// -/// Class used for providing a textual description for the API endpoint, for Swagger. +/// Class used for providing a textual description for the API endpoint, for OpenAPI. /// [ExcludeFromCodeCoverage] public class ChangePasswordEndpointSummary : Summary diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/UsersManagement/Authentication/Login/LoginEndpointSummary.cs b/src/Lumina.Presentation.Api/Core/Endpoints/UsersManagement/Authentication/Login/LoginEndpointSummary.cs index f9a59207..25f1bfb8 100644 --- a/src/Lumina.Presentation.Api/Core/Endpoints/UsersManagement/Authentication/Login/LoginEndpointSummary.cs +++ b/src/Lumina.Presentation.Api/Core/Endpoints/UsersManagement/Authentication/Login/LoginEndpointSummary.cs @@ -10,7 +10,7 @@ using System.Diagnostics.CodeAnalysis; namespace Lumina.Presentation.Api.Core.Endpoints.UsersManagement.Authentication.Login; /// -/// Class used for providing a textual description for the API endpoint, for Swagger. +/// Class used for providing a textual description for the API endpoint, for OpenAPI. /// [ExcludeFromCodeCoverage] public class LoginEndpointSummary : Summary diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/UsersManagement/Authentication/RecoverPassword/RecoverPasswordEndpointSummary.cs b/src/Lumina.Presentation.Api/Core/Endpoints/UsersManagement/Authentication/RecoverPassword/RecoverPasswordEndpointSummary.cs index 3c6a29ff..ac823e70 100644 --- a/src/Lumina.Presentation.Api/Core/Endpoints/UsersManagement/Authentication/RecoverPassword/RecoverPasswordEndpointSummary.cs +++ b/src/Lumina.Presentation.Api/Core/Endpoints/UsersManagement/Authentication/RecoverPassword/RecoverPasswordEndpointSummary.cs @@ -9,7 +9,7 @@ using System.Diagnostics.CodeAnalysis; namespace Lumina.Presentation.Api.Core.Endpoints.UsersManagement.Authentication.RecoverPassword; /// -/// Class used for providing a textual description for the API endpoint, for Swagger. +/// Class used for providing a textual description for the API endpoint, for OpenAPI. /// [ExcludeFromCodeCoverage] public class RecoverPasswordEndpointSummary : Summary diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/UsersManagement/Authentication/Register/RegisterEndpointSummary.cs b/src/Lumina.Presentation.Api/Core/Endpoints/UsersManagement/Authentication/Register/RegisterEndpointSummary.cs index 546aa0fb..24521dd2 100644 --- a/src/Lumina.Presentation.Api/Core/Endpoints/UsersManagement/Authentication/Register/RegisterEndpointSummary.cs +++ b/src/Lumina.Presentation.Api/Core/Endpoints/UsersManagement/Authentication/Register/RegisterEndpointSummary.cs @@ -13,7 +13,7 @@ using System.Diagnostics.CodeAnalysis; namespace Lumina.Presentation.Api.Core.Endpoints.UsersManagement.Authentication.Register; /// -/// Class used for providing a textual description for the API endpoint, for Swagger. +/// Class used for providing a textual description for the API endpoint, for OpenAPI. /// [ExcludeFromCodeCoverage] public class RegisterEndpointSummary : Summary diff --git a/src/Lumina.Presentation.Web/Common/Models/Libraries/LibraryModel.cs b/src/Lumina.Presentation.Web/Common/Models/Libraries/LibraryModel.cs index cdf7b67a..f0c2e68d 100644 --- a/src/Lumina.Presentation.Web/Common/Models/Libraries/LibraryModel.cs +++ b/src/Lumina.Presentation.Web/Common/Models/Libraries/LibraryModel.cs @@ -14,10 +14,15 @@ namespace Lumina.Presentation.Web.Common.Models.Libraries; public class LibraryModel { /// - /// Gets or sets the unique identifier of the library. + /// Gets or sets the unique identifier of the media library. /// public Guid? Id { get; set; } + /// + /// Gets or sets the unique identifier of the user owning the media library. + /// + public Guid? UserId { get; set; } + /// /// Gets or sets the title of the library. /// @@ -26,7 +31,7 @@ public class LibraryModel /// /// Gets or sets the type of the library. /// - public LibraryType? LibraryType { get; set; } + public string? LibraryType { get; set; } /// /// Gets or sets the collection of directories that contain the library files. diff --git a/src/Lumina.Presentation.Web/Controllers/FileSystemManagement/DirectoriesController.cs b/src/Lumina.Presentation.Web/Controllers/FileSystemManagement/DirectoriesController.cs index a8dca34d..d7109c39 100644 --- a/src/Lumina.Presentation.Web/Controllers/FileSystemManagement/DirectoriesController.cs +++ b/src/Lumina.Presentation.Web/Controllers/FileSystemManagement/DirectoriesController.cs @@ -5,7 +5,6 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using System; using System.Collections.Generic; -using System.Runtime.CompilerServices; using System.Threading; using System.Threading.Tasks; #endregion @@ -40,7 +39,7 @@ public class DirectoriesController : Controller public async Task GetDirectories([FromQuery] string path, [FromQuery] bool includeHiddenElements, CancellationToken cancellationToken) { IEnumerable response = await _apiHttpClient.GetAsync( - $"directories/get-directories?path={Uri.EscapeDataString(path)}&includeHiddenElements={includeHiddenElements}", cancellationToken: cancellationToken); + $"directories/get-directories?path={Uri.EscapeDataString(path)}&includeHiddenElements={includeHiddenElements}", cancellationToken); return Json(new { success = true, data = response }); } @@ -54,7 +53,7 @@ public class DirectoriesController : Controller public async Task GetTreeDirectories([FromQuery] string path, [FromQuery] bool includeHiddenElements, CancellationToken cancellationToken) { IEnumerable response = await _apiHttpClient.GetAsync( - $"directories/get-tree-directories?path={Uri.EscapeDataString(path)}&includeHiddenElements={includeHiddenElements}", cancellationToken: cancellationToken); + $"directories/get-tree-directories?path={Uri.EscapeDataString(path)}&includeHiddenElements={includeHiddenElements}", cancellationToken); return Json(new { success = true, data = response }); } @@ -67,7 +66,7 @@ public class DirectoriesController : Controller [HttpGet("get-directory-tree")] public async Task GetDirectoryTree([FromQuery] string path, [FromQuery] bool includeFiles, [FromQuery] bool includeHiddenElements, CancellationToken cancellationToken) { - FileSystemTreeNodeModel[] response = await _apiHttpClient.GetAsync($"directories/get-directory-tree?path={Uri.EscapeDataString(path)}&includeFiles={includeFiles}&includeHiddenElements={includeHiddenElements}", cancellationToken: cancellationToken); + FileSystemTreeNodeModel[] response = await _apiHttpClient.GetAsync($"directories/get-directory-tree?path={Uri.EscapeDataString(path)}&includeFiles={includeFiles}&includeHiddenElements={includeHiddenElements}", cancellationToken); return Json(new { success = true, data = response }); } } diff --git a/src/Lumina.Presentation.Web/Controllers/FileSystemManagement/DrivesController.cs b/src/Lumina.Presentation.Web/Controllers/FileSystemManagement/DrivesController.cs index e67881cc..e45ceca2 100644 --- a/src/Lumina.Presentation.Web/Controllers/FileSystemManagement/DrivesController.cs +++ b/src/Lumina.Presentation.Web/Controllers/FileSystemManagement/DrivesController.cs @@ -34,7 +34,7 @@ public class DrivesController : Controller [HttpGet("get-drives")] public async Task GetDrives(CancellationToken cancellationToken) { - FileSystemTreeNodeModel[] response = await _apiHttpClient.GetAsync($"drives/get-drives", cancellationToken: cancellationToken); + FileSystemTreeNodeModel[] response = await _apiHttpClient.GetAsync($"drives/get-drives", cancellationToken); return Json(new { success = true, data = new { drives = response } }); } } diff --git a/src/Lumina.Presentation.Web/Controllers/FileSystemManagement/FileSystemController.cs b/src/Lumina.Presentation.Web/Controllers/FileSystemManagement/FileSystemController.cs index eab3ea6c..61f606a5 100644 --- a/src/Lumina.Presentation.Web/Controllers/FileSystemManagement/FileSystemController.cs +++ b/src/Lumina.Presentation.Web/Controllers/FileSystemManagement/FileSystemController.cs @@ -34,7 +34,7 @@ public class FileSystemController : Controller [HttpGet("get-type")] public async Task GetType(CancellationToken cancellationToken) { - FileSystemTypeModel response = await _apiHttpClient.GetAsync($"file-system/get-type", cancellationToken: cancellationToken); + FileSystemTypeModel response = await _apiHttpClient.GetAsync($"file-system/get-type", cancellationToken); return Json(new { success = true, data = new { platformType = response.PlatformType.ToString() } }); } } diff --git a/src/Lumina.Presentation.Web/Controllers/FileSystemManagement/FilesController.cs b/src/Lumina.Presentation.Web/Controllers/FileSystemManagement/FilesController.cs index 3d000af5..e1c82663 100644 --- a/src/Lumina.Presentation.Web/Controllers/FileSystemManagement/FilesController.cs +++ b/src/Lumina.Presentation.Web/Controllers/FileSystemManagement/FilesController.cs @@ -5,7 +5,6 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using System; using System.Collections.Generic; -using System.Runtime.CompilerServices; using System.Threading; using System.Threading.Tasks; #endregion @@ -40,7 +39,7 @@ public class FilesController : Controller public async Task GetTreeFiles([FromQuery] string path, [FromQuery] bool includeHiddenElements, CancellationToken cancellationToken) { IEnumerable response = await _apiHttpClient.GetAsync( - $"files/get-tree-files?path={Uri.EscapeDataString(path)}&includeHiddenElements={includeHiddenElements}", cancellationToken: cancellationToken); + $"files/get-tree-files?path={Uri.EscapeDataString(path)}&includeHiddenElements={includeHiddenElements}", cancellationToken); return Json(new { success = true, data = response }); } @@ -54,7 +53,7 @@ public class FilesController : Controller public async Task GetFiles([FromQuery] string path, [FromQuery] bool includeHiddenElements, CancellationToken cancellationToken) { IEnumerable response = await _apiHttpClient.GetAsync( - $"files/get-files?path={Uri.EscapeDataString(path)}&includeHiddenElements={includeHiddenElements}", cancellationToken: cancellationToken); + $"files/get-files?path={Uri.EscapeDataString(path)}&includeHiddenElements={includeHiddenElements}", cancellationToken); return Json(new { success = true, data = response }); } } diff --git a/src/Lumina.Presentation.Web/Controllers/FileSystemManagement/PathController.cs b/src/Lumina.Presentation.Web/Controllers/FileSystemManagement/PathController.cs index 5be18cd2..7cf9509d 100644 --- a/src/Lumina.Presentation.Web/Controllers/FileSystemManagement/PathController.cs +++ b/src/Lumina.Presentation.Web/Controllers/FileSystemManagement/PathController.cs @@ -36,7 +36,7 @@ public class PathController : Controller [HttpGet("get-path-root")] public async Task GetPathRoot([FromQuery] string path, CancellationToken cancellationToken) { - PathSegmentModel response = await _apiHttpClient.GetAsync($"path/get-path-root?path={Uri.EscapeDataString(path)}", cancellationToken: cancellationToken); + PathSegmentModel response = await _apiHttpClient.GetAsync($"path/get-path-root?path={Uri.EscapeDataString(path)}", cancellationToken); return Json(new { success = true, data = new { root = response } }); } @@ -47,7 +47,7 @@ public class PathController : Controller [HttpGet("get-path-separator")] public async Task GetPathSeparator(CancellationToken cancellationToken) { - PathSeparatorModel response = await _apiHttpClient.GetAsync($"path/get-path-separator", cancellationToken: cancellationToken); + PathSeparatorModel response = await _apiHttpClient.GetAsync($"path/get-path-separator", cancellationToken); return Json(new { success = true, data = new { pathSeparator = response.Separator } }); } @@ -59,7 +59,7 @@ public class PathController : Controller [HttpGet("get-path-parent")] public async Task GetPathParent([FromQuery] string path, CancellationToken cancellationToken) { - PathSegmentModel[] response = await _apiHttpClient.GetAsync($"path/get-path-parent?path={Uri.EscapeDataString(path)}", cancellationToken: cancellationToken); + PathSegmentModel[] response = await _apiHttpClient.GetAsync($"path/get-path-parent?path={Uri.EscapeDataString(path)}", cancellationToken); return Json(new { success = true, data = new { pathSegments = response } }); } @@ -71,7 +71,7 @@ public class PathController : Controller [HttpGet("split")] public async Task SplitPath([FromQuery] string path, CancellationToken cancellationToken) { - PathSegmentModel[] response = await _apiHttpClient.GetAsync($"path/split?path={Uri.EscapeDataString(path)}", cancellationToken: cancellationToken); + PathSegmentModel[] response = await _apiHttpClient.GetAsync($"path/split?path={Uri.EscapeDataString(path)}", cancellationToken); return Json(new { success = true, data = new { pathSegments = response } }); } @@ -83,7 +83,7 @@ public class PathController : Controller [HttpGet("validate")] public async Task ValidatePath([FromQuery] string path, CancellationToken cancellationToken) { - PathValidModel response = await _apiHttpClient.GetAsync($"path/validate?path={Uri.EscapeDataString(path)}", cancellationToken: cancellationToken); + PathValidModel response = await _apiHttpClient.GetAsync($"path/validate?path={Uri.EscapeDataString(path)}", cancellationToken); return Json(new { success = true, data = new { isValid = response.IsValid } }); } @@ -96,7 +96,7 @@ public class PathController : Controller [HttpGet("check-path-exists")] public async Task CheckPathExists([FromQuery] string path, [FromQuery] bool includeHiddenElements, CancellationToken cancellationToken) { - PathExistsModel response = await _apiHttpClient.GetAsync($"path/check-path-exists?path={Uri.EscapeDataString(path)}&includeHiddenElements={includeHiddenElements}", cancellationToken: cancellationToken); + PathExistsModel response = await _apiHttpClient.GetAsync($"path/check-path-exists?path={Uri.EscapeDataString(path)}&includeHiddenElements={includeHiddenElements}", cancellationToken); return Json(new { success = true, data = new { exists = response.Exists } }); } } diff --git a/src/Lumina.Presentation.Web/Controllers/Library/Management/LibraryManagementController.cs b/src/Lumina.Presentation.Web/Controllers/Library/Management/LibraryManagementController.cs index 982f614b..aae4a99e 100644 --- a/src/Lumina.Presentation.Web/Controllers/Library/Management/LibraryManagementController.cs +++ b/src/Lumina.Presentation.Web/Controllers/Library/Management/LibraryManagementController.cs @@ -7,6 +7,7 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Formatters; using System; using System.Security.Claims; +using System.Threading; using System.Threading.Tasks; #endregion @@ -30,24 +31,27 @@ public class LibraryManagementController : Controller } [HttpGet("item/{id?}")] - public IActionResult EditLibrary(Guid? id = null) + public async Task EditLibrary(Guid? id = null, CancellationToken cancellationToken = default) { - LibraryModel libraryModel = new() - { - Id = id, - LibraryType = LibraryType.Book, - ContentLocations = ["a", "b", "c"], - Title = "" - }; + LibraryModel libraryModel = new(); + if (id is not null) + libraryModel = await _apiHttpClient.GetAsync($"libraries/{id}", cancellationToken); return View("/Views/Library/Management/Item.cshtml", libraryModel); } + /// + /// Adds a new media library, or updates an existing one. + /// + /// The model containing the new library data. + /// Cancellation token that can be used to stop the execution. + [ValidateAntiForgeryToken] [HttpPost("item")] - public async Task SaveLibraryAsync([FromBody] LibraryModel model) + public async Task SaveLibrary([FromBody] LibraryModel data, CancellationToken cancellationToken) { - LibraryModel response = model.Id.HasValue - ? await _apiHttpClient.PutAsync($"libraries/{model.Id}", model) - : await _apiHttpClient.PostAsync("libraries", model); - return Json(new { success = true }); + // call different API endpoints based on whether this is a new library or an existing one + LibraryModel response = data.Id.HasValue + ? await _apiHttpClient.PutAsync($"libraries/{data.Id}", data, cancellationToken) + : await _apiHttpClient.PostAsync("libraries", data, cancellationToken); + return Json(new { success = true, data = response }); } } diff --git a/src/Lumina.Presentation.Web/Controllers/UsersManagement/AuthController.cs b/src/Lumina.Presentation.Web/Controllers/UsersManagement/AuthController.cs index 0c2e2923..f4cdd624 100644 --- a/src/Lumina.Presentation.Web/Controllers/UsersManagement/AuthController.cs +++ b/src/Lumina.Presentation.Web/Controllers/UsersManagement/AuthController.cs @@ -14,6 +14,7 @@ using System; using System.Collections.Generic; using System.Security.Claims; using System.Text.Json; +using System.Threading; using System.Threading.Tasks; #endregion @@ -113,15 +114,16 @@ public class AuthController : Controller /// Registers a new account. /// /// User credentials used for registration. + /// Cancellation token that can be used to stop the execution. [AllowAnonymous] [ValidateAntiForgeryToken] [HttpPost("register")] - public async Task Register([FromBody] RegisterRequestModel data) + public async Task Register([FromBody] RegisterRequestModel data, CancellationToken cancellationToken) { // call different endpoints based on the view hidden field - registration for normal users, or initial application admin account setup string endpoint = data.RegistrationType == "Admin" ? "initialization" : "auth/register"; // attempt API registration - RegisterResponseModel response = await _apiHttpClient.PostAsync(endpoint, data); + RegisterResponseModel response = await _apiHttpClient.PostAsync(endpoint, data, cancellationToken); return Json(new { success = true, data = response }); } @@ -129,15 +131,16 @@ public class AuthController : Controller /// Logs in an account. /// /// User credentials used for login. + /// Cancellation token that can be used to stop the execution. [AllowAnonymous] [ValidateAntiForgeryToken] [HttpPost("login")] - public async Task Login([FromBody] LoginRequestModel data) + public async Task Login([FromBody] LoginRequestModel data, CancellationToken cancellationToken) { try { // attempt API registration - LoginResponseModel response = await _apiHttpClient.PostAsync("auth/login", data); + LoginResponseModel response = await _apiHttpClient.PostAsync("auth/login", data, cancellationToken); // store the received token in a secure cookie Response.Cookies.Delete("Token"); Response.Cookies.Append("Token", _cryptographyService.Encrypt(response.Token!), new CookieOptions @@ -193,12 +196,13 @@ public class AuthController : Controller /// Recovers the password of an account. /// /// User credentials used for password recovery. + /// Cancellation token that can be used to stop the execution. [AllowAnonymous] [ValidateAntiForgeryToken] [HttpPost("recover-password")] - public async Task RecoverPassword([FromBody] RecoverPasswordRequestModel data) + public async Task RecoverPassword([FromBody] RecoverPasswordRequestModel data, CancellationToken cancellationToken) { - RecoverPasswordResponseModel response = await _apiHttpClient.PostAsync("auth/recover-password", data); + RecoverPasswordResponseModel response = await _apiHttpClient.PostAsync("auth/recover-password", data, cancellationToken); return Json(new { success = true, data = response }); } @@ -206,12 +210,13 @@ public class AuthController : Controller /// Changes the password of an account. /// /// User credentials used for password change. + /// Cancellation token that can be used to stop the execution. [ValidateAntiForgeryToken] [HttpPost("change-password")] - public async Task ChangePassword([FromBody] ChangePasswordRequestModel data) + public async Task ChangePassword([FromBody] ChangePasswordRequestModel data, CancellationToken cancellationToken) { data = data with { Username = User?.Identity?.Name }; // assign the currently logged in user as the user for which to change the password - ChangePasswordResponseModel response = await _apiHttpClient.PostAsync("auth/change-password", data); + ChangePasswordResponseModel response = await _apiHttpClient.PostAsync("auth/change-password", data, cancellationToken); return Json(new { success = true, data = response }); } } diff --git a/src/Lumina.Presentation.Web/Views/Auth/Login.cshtml b/src/Lumina.Presentation.Web/Views/Auth/Login.cshtml index 55a11fec..90b9185c 100644 --- a/src/Lumina.Presentation.Web/Views/Auth/Login.cshtml +++ b/src/Lumina.Presentation.Web/Views/Auth/Login.cshtml @@ -39,7 +39,7 @@
- +
diff --git a/src/Lumina.Presentation.Web/Views/Auth/RecoverPassword.cshtml b/src/Lumina.Presentation.Web/Views/Auth/RecoverPassword.cshtml index 6e6263df..a5e3dee8 100644 --- a/src/Lumina.Presentation.Web/Views/Auth/RecoverPassword.cshtml +++ b/src/Lumina.Presentation.Web/Views/Auth/RecoverPassword.cshtml @@ -48,7 +48,7 @@
- +
@section Scripts { diff --git a/src/Lumina.Presentation.Web/Views/Library/Management/Item.cshtml b/src/Lumina.Presentation.Web/Views/Library/Management/Item.cshtml index 1af0a4bd..e46089de 100644 --- a/src/Lumina.Presentation.Web/Views/Library/Management/Item.cshtml +++ b/src/Lumina.Presentation.Web/Views/Library/Management/Item.cshtml @@ -11,15 +11,18 @@ var scriptId = ScriptIdentifierHelper.GenerateScriptId(); } +@inject IUrlService _urlService + @model LibraryModel @await Component.InvokeAsync("FileSystemBrowser")
-
+ @Html.AntiForgeryToken() +

@(id is not null ? "Edit" : "Add New") Library

@@ -52,9 +55,44 @@
-
Book
+
Written Content
Book
- +
E Book
+
Book Series
+
Comic Book
+
Comic Series
+
Magazine
+
Manga
+
Graphic Novel
+
Academic Paper
+
Sheet Music
+
Screenplay
+
Video Content
+
Tv Show
+
Movie
+
Film Series
+
Film Franchise
+
Concert
+
Documentary
+
Tutorial
+
Personal
+
Anime
+
Youtube
+
Videoclip
+
Audio Content
+
Music
+
Audio Book
+
Live Performance
+
Interview
+
Cover
+
Remix
+
Soundeffect
+
Podcast
+
Radio Show
+
Visual Content
+
Photo Album
+
Miscellaneous Content
+
Other
@@ -85,9 +123,18 @@ + +
+ + + +
@section Scripts {