Adds media libraries management view

This commit is contained in:
BinaryAlley committed 2025-01-11 23:11:33 +02:00
1 parent b593cbce93
commit d7c8478101
162 files changed
+3741 -171

No files matched your search

@@ -9,5 +9,5 @@ public enum AuthorizationPermission
CanViewUsers,
CanDeleteUsers,
CanRegisterUsers,
canCreateLibraries
CanCreateLibraries
}
@@ -32,7 +32,7 @@ public class Genre : ValueObject
/// </summary>
/// <param name="name">The value of the genre.</param>
/// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="Genre"/>, or an error message.
/// An <see cref="ErrorOr{TValue}"/> containing either a successfuly created <see cref="Genre"/>, or an error message.
/// </returns>
public static ErrorOr<Genre> Create(string? name)
{
@@ -49,7 +49,7 @@ public class LanguageInfo : ValueObject
/// <param name="languageName">The full name of the language in English.</param>
/// <param name="nativeName">The optional native name of the language.</param>
/// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="LanguageInfo"/>, or an error message.
/// An <see cref="ErrorOr{TValue}"/> containing either a successfuly created <see cref="LanguageInfo"/>, or an error message.
/// </returns>
public static ErrorOr<LanguageInfo> Create(string? languageCode, string? languageName, Optional<string> nativeName)
{
@@ -81,7 +81,7 @@ public class ReleaseInfo : ValueObject
/// <param name="releaseCountry">The optional country or region of release.</param>
/// <param name="releaseVersion">The optional release version or edition.</param>
/// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="ReleaseInfo"/>, or an error message.
/// An <see cref="ErrorOr{TValue}"/> containing either a successfuly created <see cref="ReleaseInfo"/>, or an error message.
/// </returns>
public static ErrorOr<ReleaseInfo> Create(
Optional<DateOnly> originalReleaseDate,
@@ -32,7 +32,7 @@ public class Tag : ValueObject
/// </summary>
/// <param name="name">The value of the tag.</param>
/// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="Tag"/>, or an error message.
/// An <see cref="ErrorOr{TValue}"/> containing either a successfuly created <see cref="Tag"/>, or an error message.
/// </returns>
public static ErrorOr<Tag> Create(string? name)
{
@@ -102,7 +102,7 @@ public class AudioMetadata : BaseMetadata
/// <param name="genres">The genres of the audio.</param>
/// <param name="tags">The tags associated with the audio.</param>
/// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="AudioMetadata"/>, or an error message.
/// An <see cref="ErrorOr{TValue}"/> containing either a successfuly created <see cref="AudioMetadata"/>, or an error message.
/// </returns>
public static ErrorOr<AudioMetadata> Create(
string title,
@@ -55,7 +55,7 @@ public sealed class Directory : FileSystemItem
/// <param name="dateModified">The date and time the directory was last modified. Can be optional if unknown.</param>
/// <param name="status">The status of the file system item.</param>
/// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="Directory"/>, or an error message.
/// An <see cref="ErrorOr{TValue}"/> containing either a successfuly created <see cref="Directory"/>, or an error message.
/// </returns>
public static ErrorOr<Directory> Create(
string path,
@@ -87,7 +87,7 @@ public sealed class Directory : FileSystemItem
/// <param name="dateModified">The date and time the directory was last modified. Can be optional if unknown.</param>
/// <param name="status">The status of the file system item.</param>
/// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="Directory"/>, or an error message.
/// An <see cref="ErrorOr{TValue}"/> containing either a successfuly created <see cref="Directory"/>, or an error message.
/// </returns>
public static ErrorOr<Directory> Create(
FileSystemPathId id,
@@ -112,7 +112,7 @@ public sealed class Directory : FileSystemItem
/// Updates the last modified date of the file system item.
/// </summary>
/// <param name="date">The new date and time of last modification.</param>
/// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successfull operation, or an error.</returns>
/// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successful operation, or an error.</returns>
public ErrorOr<Updated> UpdateLastModified(DateTime date)
{
DateModified = date;
@@ -123,7 +123,7 @@ public sealed class Directory : FileSystemItem
/// Adds a file system item to the directory.
/// </summary>
/// <param name="item">The file system item to add.</param>
/// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successfull operation, or an error.</returns>
/// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successful operation, or an error.</returns>
public ErrorOr<Updated> AddItem(FileSystemItem item)
{
_items.Add(item);
@@ -134,7 +134,7 @@ public sealed class Directory : FileSystemItem
/// Removes a file system item from the directory.
/// </summary>
/// <param name="item">The file system item to remove.</param>
/// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successfull operation, or an error.</returns>
/// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successful operation, or an error.</returns>
public ErrorOr<Updated> RemoveItem(FileSystemItem item)
{
_items.Remove(item);
@@ -56,7 +56,7 @@ public sealed class File : FileSystemItem
/// <param name="size">The size of the file in bytes.</param>
/// <param name="status">The status of the file system item.</param>
/// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="File"/>, or an error message.
/// An <see cref="ErrorOr{TValue}"/> containing either a successfuly created <see cref="File"/>, or an error message.
/// </returns>
public static ErrorOr<File> Create(
string path,
@@ -92,7 +92,7 @@ public sealed class File : FileSystemItem
/// <param name="size">The size of the file in bytes.</param>
/// <param name="status">The status of the file system item.</param>
/// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="File"/>, or an error message.
/// An <see cref="ErrorOr{TValue}"/> containing either a successfuly created <see cref="File"/>, or an error message.
/// </returns>
public static ErrorOr<File> Create(
FileSystemPathId id,
@@ -119,7 +119,7 @@ public sealed class File : FileSystemItem
/// Updates the last modified date of the file system item.
/// </summary>
/// <param name="date">The new date and time of last modification.</param>
/// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successfull operation, or an error.</returns>
/// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successful operation, or an error.</returns>
public ErrorOr<Updated> UpdateLastModified(DateTime date)
{
DateModified = date;
@@ -130,7 +130,7 @@ public sealed class File : FileSystemItem
/// Updates the size of the file.
/// </summary>
/// <param name="newSize">The new size, in bytes.</param>
/// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successfull operation, or an error.</returns>
/// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successful operation, or an error.</returns>
public ErrorOr<Updated> UpdateSize(long newSize)
{
Size = newSize;
@@ -141,7 +141,7 @@ public sealed class File : FileSystemItem
/// Renames the file system item to the specified new name.
/// </summary>
/// <param name="newName">The new name for the file system item.</param>
/// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successfull operation, or an error.</returns>
/// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successful operation, or an error.</returns>
public ErrorOr<Updated> Rename(string newName)
{
if (string.IsNullOrWhiteSpace(newName))
@@ -37,7 +37,7 @@ public sealed class UnixRootItem : FileSystemItem
/// </summary>
/// <param name="status">The status of the file system root item.</param>
/// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="UnixRootItem"/>, or an error message.
/// An <see cref="ErrorOr{TValue}"/> containing either a successfuly created <see cref="UnixRootItem"/>, or an error message.
/// </returns>
public static ErrorOr<UnixRootItem> Create(FileSystemItemStatus status = FileSystemItemStatus.Accessible)
{
@@ -38,7 +38,7 @@ public sealed class WindowsRootItem : FileSystemItem
/// <param name="name">The name of the file system root item.</param>
/// <param name="status">The status of the file system root item.</param>
/// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="WindowsRootItem"/>, or an error message.
/// An <see cref="ErrorOr{TValue}"/> containing either a successfuly created <see cref="WindowsRootItem"/>, or an error message.
/// </returns>
public static ErrorOr<WindowsRootItem> Create(
string path,
@@ -65,7 +65,7 @@ public sealed class WindowsRootItem : FileSystemItem
/// <param name="name">The name of the file system root item.</param>
/// <param name="status">The status of the file system root item.</param>
/// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="WindowsRootItem"/>, or an error message.
/// An <see cref="ErrorOr{TValue}"/> containing either a successfuly created <see cref="WindowsRootItem"/>, or an error message.
/// </returns>
public static ErrorOr<WindowsRootItem> Create(
FileSystemPathId id,
@@ -52,7 +52,7 @@ public abstract class FileSystemItem : AggregateRoot<FileSystemPathId>
/// Sets the status of the filesystem item.
/// </summary>
/// <param name="status">The status to be set.</param>
/// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successfull operation, or an error.</returns>
/// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successful operation, or an error.</returns>
public ErrorOr<Updated> SetStatus(FileSystemItemStatus status)
{
Status = status;
@@ -63,7 +63,7 @@ public abstract class FileSystemItem : AggregateRoot<FileSystemPathId>
/// Sets the parent of the filesystem item.
/// </summary>
/// <param name="parent">The file system item to be set as parent.</param>
/// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successfull operation, or an error.</returns>
/// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successful operation, or an error.</returns>
public ErrorOr<Updated> SetParent(FileSystemItem parent)
{
if (parent is not null)
@@ -30,7 +30,7 @@ internal class FileSystemStructureSeedService : IFileSystemStructureSeedService
/// Sets up the default file system directories needed by the application.
/// </summary>
/// <param name="rootPath">The base path where the directories will be created relative to.</param>
/// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successfull operation, or an error.</returns>
/// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successful operation, or an error.</returns>
public ErrorOr<Created> SetDefaultDirectories(string rootPath)
{
// make sure the root path exists
@@ -13,6 +13,6 @@ public interface IFileSystemStructureSeedService
/// Sets up the default file system directories needed by the application.
/// </summary>
/// <param name="rootPath">The base path where the directories will be created relative to.</param>
/// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successfull operation, or an error.</returns>
/// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successful operation, or an error.</returns>
ErrorOr<Created> SetDefaultDirectories(string rootPath);
}
@@ -39,7 +39,7 @@ public sealed class FileSystemPathId : ValueObject
/// </summary>
/// <param name="path">The path of the file system item.</param>
/// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="FileSystemPathId"/> or an error message.
/// An <see cref="ErrorOr{TValue}"/> containing either a successfuly created <see cref="FileSystemPathId"/> or an error message.
/// </returns>
public static ErrorOr<FileSystemPathId> Create(string path)
{
@@ -49,7 +49,7 @@ public class PathSegment : ValueObject
/// <param name="isDirectory">Value indicating if the current path segment is a file system directory or not.</param>
/// <param name="isDrive">Value indicating if the current path segment is a file system drive or not.</param>
/// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="PathSegment"/> or an error message.
/// An <see cref="ErrorOr{TValue}"/> containing either a successfuly created <see cref="PathSegment"/> or an error message.
/// </returns>
public static ErrorOr<PathSegment> Create(string name, bool isDirectory, bool isDrive)
{
@@ -98,7 +98,7 @@ public class StreamInfo : ValueObject
/// <param name="sampleRate">The sample rate of the stream (for audio).</param>
/// <param name="channels">The number of channels (for audio).</param>
/// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="StreamInfo"/>, or an error message.
/// An <see cref="ErrorOr{TValue}"/> containing either a successfuly created <see cref="StreamInfo"/>, or an error message.
/// </returns>
public static ErrorOr<StreamInfo> Create(
string streamId,
@@ -0,0 +1,20 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Common.Events;
using System;
using System.Diagnostics;
#endregion
namespace Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.Events;
/// <summary>
/// Domain event raised when a libary is deleted.
/// </summary>
/// <param name="Id">The Id of the domain event.</param>
/// <param name="Library">The library that was deleted.</param>
/// <param name="OccurredOnUtc">The date and time when the domain event occurred.</param>
[DebuggerDisplay("Id: {Library.Id} Title: {Library.Title}")]
public record LibraryDeletedDomainEvent(
Guid Id,
Library Library,
DateTime OccurredOnUtc
) : IDomainEvent;
@@ -9,6 +9,7 @@ using Lumina.Domain.Core.BoundedContexts.UserManagementBoundedContext.UserAggreg
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
#endregion
namespace Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate;
@@ -86,7 +87,7 @@ public class Library : AggregateRoot<LibraryId>
/// <param name="contentLocations">The list of file system paths that make up the media library.</param>
/// <param name="coverImageSourcePath">The path of the image file chosen by the user to be used as the cover for the library.</param>
/// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="Library"/>, or an error message.
/// An <see cref="ErrorOr{TValue}"/> containing either a successfuly created <see cref="Library"/>, or an error message.
/// </returns>
public static ErrorOr<Library> Create(
Guid userId,
@@ -124,7 +125,7 @@ public class Library : AggregateRoot<LibraryId>
/// <param name="contentLocations">The list of file system paths that make up the media library.</param>
/// <param name="coverImageSourcePath">The path of the image file chosen by the user to be used as the cover for the library.</param>
/// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="Library"/>, or an error message.
/// An <see cref="ErrorOr{TValue}"/> containing either a successfuly created <see cref="Library"/>, or an error message.
/// </returns>
public static ErrorOr<Library> Create(
LibraryId id,
@@ -161,4 +162,20 @@ public class Library : AggregateRoot<LibraryId>
{
CoverImage = path;
}
/// <summary>
/// Marks the current library as deleted.
/// </summary>
public ErrorOr<Deleted> Delete()
{
// clear all existing events since they become irrelevant when the entity is deleted, and they dont need to be processed
_domainEvents.Clear();
// only add the delete event if it hasn't been added already
if (!_domainEvents.Any(e => e is LibraryDeletedDomainEvent))
_domainEvents.Add(new LibraryDeletedDomainEvent(Guid.NewGuid(), this, DateTime.UtcNow));
// TODO: perhaps trigger events for removing contents related to the removed library (media metadata, etc)?
return Result.Deleted;
}
}
@@ -35,7 +35,7 @@ public sealed class User : AggregateRoot<UserId>
/// </summary>
/// <param name="username">The username of the user.</param>
/// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="User"/>, or an error message.
/// An <see cref="ErrorOr{TValue}"/> containing either a successfuly created <see cref="User"/>, or an error message.
/// </returns>
public static ErrorOr<User> Create(
string username)
@@ -51,7 +51,7 @@ public sealed class User : AggregateRoot<UserId>
/// <param name="id">The object representing the id of the user.</param>
/// <param name="username">The username of the user.</param>
/// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="User"/>, or an error message.
/// An <see cref="ErrorOr{TValue}"/> containing either a successfuly created <see cref="User"/>, or an error message.
/// </returns>
public static ErrorOr<User> Create(
UserId id,
@@ -96,7 +96,7 @@ public class VideoMetadata : BaseMetadata
/// <param name="genres">The genres of the video.</param>
/// <param name="tags">The tags associated with the video.</param>
/// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="VideoMetadata"/>, or an error message.
/// An <see cref="ErrorOr{TValue}"/> containing either a successfuly created <see cref="VideoMetadata"/>, or an error message.
/// </returns>
public static ErrorOr<VideoMetadata> Create(
string title,
@@ -206,7 +206,7 @@ public sealed class Book : AggregateRoot<BookId>
/// <param name="contributors">The list of media contributors of the book.</param>
/// <param name="ratings">The list of ratings for the book.</param>
/// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="Book"/>, or an error message.
/// An <see cref="ErrorOr{TValue}"/> containing either a successfuly created <see cref="Book"/>, or an error message.
/// </returns>
public static ErrorOr<Book> Create(
WrittenContentMetadata metadata,
@@ -276,7 +276,7 @@ public sealed class Book : AggregateRoot<BookId>
/// <param name="contributors">The list of media contributors of the book.</param>
/// <param name="ratings">The list of ratings for the book.</param>
/// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="Book"/>, or an error message.
/// An <see cref="ErrorOr{TValue}"/> containing either a successfuly created <see cref="Book"/>, or an error message.
/// </returns>
public static ErrorOr<Book> Create(
BookId id,
@@ -56,7 +56,7 @@ public sealed class BookSeries : Entity<BookSeriesId>
/// <param name="isComplete">The current status of the book series.</param>
/// <param name="books">The books of the book series.</param>
/// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="BookSeries"/>, or an error message.
/// An <see cref="ErrorOr{TValue}"/> containing either a successfuly created <see cref="BookSeries"/>, or an error message.
/// </returns>
public static ErrorOr<BookSeries> Create(
BookSeriesId id,
@@ -80,7 +80,7 @@ public sealed class BookSeries : Entity<BookSeriesId>
/// <param name="isComplete">The current status of the book series.</param>
/// <param name="books">The books of the book series.</param>
/// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="BookSeries"/>, or an error message.
/// An <see cref="ErrorOr{TValue}"/> containing either a successfuly created <see cref="BookSeries"/>, or an error message.
/// </returns>
public static ErrorOr<BookSeries> Create(
WrittenContentMetadata metadata,
@@ -42,7 +42,7 @@ public class BookRating : Rating
/// <param name="source">The optional source of the rating.</param>
/// <param name="voteCount">The optional number of votes or reviews.</param>
/// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="Rating"/>, or an error message.
/// An <see cref="ErrorOr{TValue}"/> containing either a successfuly created <see cref="Rating"/>, or an error message.
/// </returns>
public static ErrorOr<BookRating> Create(decimal value, decimal maxValue, Optional<BookRatingSource> source, Optional<int> voteCount)
{
@@ -69,7 +69,7 @@ public class WrittenContentMetadata : BaseMetadata
/// <param name="publisher">The publisher of the written content, if applicable.</param>
/// <param name="pageCount">The number of pages in the written content, if applicable.</param>
/// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="WrittenContentMetadata"/>, or an error message.
/// An <see cref="ErrorOr{TValue}"/> containing either a successfuly created <see cref="WrittenContentMetadata"/>, or an error message.
/// </returns>
public static ErrorOr<WrittenContentMetadata> Create(
string title,