Implements directory browser dialog, part 1: file system treeview

This commit is contained in:
BinaryAlley committed 2024-09-15 13:07:53 +03:00
1 parent 4a53348013
commit 4e4ecbbfca
318 files changed
+6012 -1184

No files matched your search

@@ -1,13 +1,15 @@
#region ========================================================================= USING =====================================================================================
using Mediator;
using ErrorOr;
using FluentValidation;
using Mediator;
using System.Threading;
using System.Threading.Tasks;
#endregion
namespace Lumina.Application.Common.Behaviors;
/// <summary>
/// Behavior pipeline for the register command
/// Represents a validation behavior in the MediatR pipeline for handling requests and responses.
/// </summary>
/// <typeparam name="TRequest">The type representing a request. It should implement <see cref="IRequest{TResponse}"/>.</typeparam>
/// <typeparam name="TResponse">The type representing a response. It should implement <see cref="IErrorOr"/> interface.</typeparam>
@@ -15,7 +17,7 @@ public class ValidationBehavior<TRequest, TResponse> : IPipelineBehavior<TReques
where TResponse : IErrorOr
{
#region ================================================================== FIELD MEMBERS ================================================================================
private readonly IValidator<TRequest>? validator;
private readonly IValidator<TRequest>? _validator;
#endregion
#region ====================================================================== CTOR =====================================================================================
@@ -25,7 +27,7 @@ public class ValidationBehavior<TRequest, TResponse> : IPipelineBehavior<TReques
/// <param name="validator">The validator used in this behavior pipeline for the Mediator commands and queries.</param>
public ValidationBehavior(IValidator<TRequest>? validator = null)
{
this.validator = validator;
_validator = validator;
}
#endregion
@@ -39,13 +41,13 @@ public class ValidationBehavior<TRequest, TResponse> : IPipelineBehavior<TReques
public async ValueTask<TResponse> Handle(TRequest request, CancellationToken cancellationToken, MessageHandlerDelegate<TRequest, TResponse> next)
{
// if there is no validator, just invoke the handler
if (validator is null)
return await next(request, cancellationToken);
if (_validator is null)
return await next(request, cancellationToken).ConfigureAwait(false);
// before the handler of the command is executed
var validationResult = await validator.ValidateAsync(request, cancellationToken);
var validationResult = await _validator.ValidateAsync(request, cancellationToken).ConfigureAwait(false);
// if there are no validation errors, invoke the command handler
if (validationResult.IsValid)
return await next(request, cancellationToken);
return await next(request, cancellationToken).ConfigureAwait(false);
// after the command handler is executed
var errors = validationResult.Errors.ConvertAll(validationFailure => Error.Validation(description: validationFailure.ErrorMessage));
// the compiler doesn't know there is an implicit converter from a list of errors to the ErrorOr object, and unfortunately, there is no way around this but to use some magic
@@ -1,40 +1,41 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Common.Primitives;
using System;
using System.Text.Json;
using System.Text.Json.Serialization;
using Lumina.Domain.Common.Primitives;
#endregion
namespace Lumina.Application.Common.Converters;
/// <summary>
/// Converts an <see cref="Optional{T}"/> to and from JSON.
/// Converts an <see cref="Optional{TValue}"/> to and from JSON.
/// </summary>
/// <typeparam name="T">The type of the value represented by the <see cref="Optional{T}"/> structure.</typeparam>
public class OptionalJsonConverter<T> : JsonConverter<Optional<T>>
/// <typeparam name="TValue">The type of the value represented by the <see cref="Optional{TValue}"/> structure.</typeparam>
public class OptionalJsonConverter<TValue> : JsonConverter<Optional<TValue>>
{
#region ===================================================================== METHODS ===================================================================================
/// <summary>
/// Reads and converts the JSON to an instance of <see cref="Optional{T}"/>.
/// Reads and converts the JSON to an instance of <see cref="Optional{TValue}"/>.
/// </summary>
/// <param name="reader">The <see cref="Utf8JsonReader"/> to read from.</param>
/// <param name="typeToConvert">The type to convert.</param>
/// <param name="options">An object that specifies serialization options to use.</param>
/// <returns>The converted <see cref="Optional{T}"/> value.</returns>
public override Optional<T> Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
/// <returns>The converted <see cref="Optional{TValue}"/> value.</returns>
public override Optional<TValue> Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
if (reader.TokenType == JsonTokenType.Null)
return Optional<T>.None();
var value = JsonSerializer.Deserialize<T>(ref reader, options);
return Optional<T>.Some(value!);
return Optional<TValue>.None();
var value = JsonSerializer.Deserialize<TValue>(ref reader, options);
return Optional<TValue>.Some(value!);
}
/// <summary>
/// Writes an <see cref="Optional{T}"/> value as JSON.
/// Writes an <see cref="Optional{TValue}"/> value as JSON.
/// </summary>
/// <param name="writer">The <see cref="Utf8JsonWriter"/> to write to.</param>
/// <param name="value">The value to convert to JSON.</param>
/// <param name="options">An object that specifies serialization options to use.</param>
public override void Write(Utf8JsonWriter writer, Optional<T> value, JsonSerializerOptions options)
public override void Write(Utf8JsonWriter writer, Optional<TValue> value, JsonSerializerOptions options)
{
if (value.HasValue)
JsonSerializer.Serialize(writer, value.Value, options);
@@ -1,7 +1,8 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Common.Primitives;
using System;
using System.Text.Json;
using System.Text.Json.Serialization;
using Lumina.Domain.Common.Primitives;
#endregion
namespace Lumina.Application.Common.Converters;
@@ -16,7 +17,7 @@ public class OptionalJsonConverterFactory : JsonConverterFactory
/// Determines whether the converter can convert the specified type.
/// </summary>
/// <param name="typeToConvert">The type to check for convertibility.</param>
/// <returns><see langword="true"/> if the type is <see cref="Optional{T}"/>, <see langword="false"/> otherwise.</returns>
/// <returns><see langword="true"/> if the type is <see cref="Optional{TValue}"/>, <see langword="false"/> otherwise.</returns>
public override bool CanConvert(Type typeToConvert)
{
if (!typeToConvert.IsGenericType)
@@ -29,7 +30,7 @@ public class OptionalJsonConverterFactory : JsonConverterFactory
/// </summary>
/// <param name="typeToConvert">The type for which to create a converter.</param>
/// <param name="options">The serializer options to use.</param>
/// <returns>A converter for <see cref="Optional{T}"/>.</returns>
/// <returns>A converter for <see cref="Optional{TValue}"/>.</returns>
public override JsonConverter CreateConverter(Type typeToConvert, JsonSerializerOptions options)
{
Type valueType = typeToConvert.GetGenericArguments()[0];
@@ -1,7 +1,7 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Common.DataAccess.Repositories.Common.Actions;
using Lumina.Application.Common.DataAccess.Repositories.Common.Base;
using Lumina.Application.Common.Models.Books;
using Lumina.Contracts.Models.WrittenContentLibrary.BookLibrary;
#endregion
namespace Lumina.Application.Common.DataAccess.Repositories.Books;
@@ -9,8 +9,8 @@ namespace Lumina.Application.Common.DataAccess.Repositories.Books;
/// <summary>
/// Interface for the repository for books.
/// </summary>
public interface IBookRepository : IRepository<BookDto>,
IInsertRepositoryAction<BookDto>,
IGetAllRepositoryAction<BookDto>
public interface IBookRepository : IRepository<BookModel>,
IInsertRepositoryAction<BookModel>,
IGetAllRepositoryAction<BookModel>
{
}
@@ -1,5 +1,6 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using System.Threading.Tasks;
#endregion
namespace Lumina.Application.Common.DataAccess.Repositories.Common.Actions;
@@ -13,7 +14,7 @@ public interface IDeleteAllRepositoryAction
/// <summary>
/// Deletes all entities from the storage medium.
/// </summary>
/// <returns>An <see cref="ErrorOr{T}"/> representing either a successfull operation, or an error.</returns>
/// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successfull operation, or an error.</returns>
Task<ErrorOr<Deleted>> DeleteAllAsync();
#endregion
}
@@ -1,5 +1,7 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using System.Threading;
using System.Threading.Tasks;
#endregion
namespace Lumina.Application.Common.DataAccess.Repositories.Common.Actions;
@@ -16,7 +18,7 @@ public interface IDeleteByIdRepositoryAction<TId> where TId : notnull
/// </summary>
/// <param name="id">The id of the element to be deleted.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="ErrorOr{T}"/> representing either a successfull operation, or an error.</returns>
/// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successfull operation, or an error.</returns>
Task<ErrorOr<Deleted>> DeleteByIdAsync(TId id, CancellationToken cancellationToken);
#endregion
}
@@ -1,6 +1,9 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using Lumina.Application.Common.Models.Common;
using Lumina.Contracts.Models.Common;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
#endregion
namespace Lumina.Application.Common.DataAccess.Repositories.Common.Actions;
@@ -16,7 +19,7 @@ public interface IGetAllRepositoryAction<TModel> where TModel : IStorageEntity
/// Gets all data of type <typeparamref name="TModel"/> from the storage medium.
/// </summary>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="ErrorOr{T}"/> containing either a collection of <typeparamref name="TModel"/>, or an error.</returns>
/// <returns>An <see cref="ErrorOr{TValue}"/> containing either a collection of <typeparamref name="TModel"/>, or an error.</returns>
Task<ErrorOr<IEnumerable<TModel>>> GetAllAsync(CancellationToken cancellationToken);
#endregion
}
@@ -1,6 +1,8 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using Lumina.Application.Common.Models.Common;
using Lumina.Contracts.Models.Common;
using System.Threading;
using System.Threading.Tasks;
#endregion
namespace Lumina.Application.Common.DataAccess.Repositories.Common.Actions;
@@ -19,7 +21,7 @@ public interface IGetByIdRepositoryAction<TModel, TId> where TModel : IStorageEn
/// </summary>
/// <param name="id">The id of the element to get.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="ErrorOr{T}"/> containing either a <typeparamref name="TModel"/> identified by <paramref name="id"/>, or an error.</returns>
/// <returns>An <see cref="ErrorOr{TValue}"/> containing either a <typeparamref name="TModel"/> identified by <paramref name="id"/>, or an error.</returns>
Task<ErrorOr<TModel?>> GetByIdAsync(TId id, CancellationToken cancellationToken);
#endregion
}
@@ -1,6 +1,8 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using Lumina.Application.Common.Models.Common;
using Lumina.Contracts.Models.Common;
using System.Threading;
using System.Threading.Tasks;
#endregion
namespace Lumina.Application.Common.DataAccess.Repositories.Common.Actions;
@@ -17,7 +19,7 @@ public interface IInsertRepositoryAction<TModel> where TModel : IStorageEntity
/// </summary>
/// <param name="data">The element to be saved.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="ErrorOr{T}"/> representing either a successfull operation, or an error.</returns>
/// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successfull operation, or an error.</returns>
Task<ErrorOr<Created>> InsertAsync(TModel data, CancellationToken cancellationToken);
#endregion
}
@@ -1,6 +1,8 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using Lumina.Application.Common.Models.Common;
using Lumina.Contracts.Models.Common;
using System.Threading;
using System.Threading.Tasks;
#endregion
namespace Lumina.Application.Common.DataAccess.Repositories.Common.Actions;
@@ -17,7 +19,7 @@ public interface IUpdateRepositoryAction<TModel> where TModel : IStorageEntity
/// </summary>
/// <param name="data">The element that will be updated.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="ErrorOr{T}"/> representing either a successfull operation, or an error.</returns>
/// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successfull operation, or an error.</returns>
Task<ErrorOr<Updated>> UpdateAsync(TModel data, CancellationToken cancellationToken);
#endregion
}
@@ -1,5 +1,6 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Common.Models.Common;
using Lumina.Contracts.Models.Common;
#endregion
namespace Lumina.Application.Common.DataAccess.Repositories.Common.Base;
@@ -1,4 +1,9 @@
namespace Lumina.Application.Common.DataAccess.UoW;
#region ========================================================================= USING =====================================================================================
using System.Threading;
using System.Threading.Tasks;
#endregion
namespace Lumina.Application.Common.DataAccess.UoW;
/// <summary>
/// Interaction boundary with the Data Access Layer.
@@ -0,0 +1,31 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Contracts.Responses.FileManagement;
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Entities;
using Mapster;
#endregion
namespace Lumina.Application.Common.Mapping.FileManagement;
/// <summary>
/// Mapping configuration for file system directories between the domain object and the presentation object.
/// </summary>
public class DirectoryMappingConfig : IRegister
{
#region ===================================================================== METHODS ===================================================================================
/// <summary>
/// Registers the mapping configuration.
/// </summary>
/// <param name="config">The type adapter configuration.</param>
public void Register(TypeAdapterConfig config)
{
config.NewConfig<Directory, FileSystemTreeNodeResponse>()
.Map(dest => dest.Name, src => src.Name)
.Map(dest => dest.Path, src => src.Id.Path)
.Map(dest => dest.ItemType, src => src.Type)
.Map(dest => dest.IsExpanded, () => false)
.Map(dest => dest.ChildrenLoaded, () => false)
.Map(dest => dest.Children, src => src.Items)
.MapToConstructor(true);
}
#endregion
}
@@ -0,0 +1,30 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Contracts.Responses.FileManagement;
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Entities;
using Mapster;
#endregion
namespace Lumina.Application.Common.Mapping.FileManagement;
/// <summary>
/// Mapping configuration for file system files between the domain object and the presentation object.
/// </summary>
public class FileMappingConfig : IRegister
{
#region ===================================================================== METHODS ===================================================================================
/// <summary>
/// Registers the mapping configuration.
/// </summary>
/// <param name="config">The type adapter configuration.</param>
public void Register(TypeAdapterConfig config)
{
config.NewConfig<File, FileSystemTreeNodeResponse>()
.Map(dest => dest.Name, src => src.Name)
.Map(dest => dest.Path, src => src.Id.Path)
.Map(dest => dest.ItemType, src => src.Type)
.Map(dest => dest.IsExpanded, () => false)
.Map(dest => dest.ChildrenLoaded, () => false)
.MapToConstructor(true);
}
#endregion
}
@@ -0,0 +1,60 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Contracts.Enums.FileSystem;
using Lumina.Contracts.Responses.FileManagement;
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate;
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Entities;
using Mapster;
using System.Collections.Generic;
#endregion
namespace Lumina.Application.Common.Mapping.FileManagement;
/// <summary>
/// Mapping configuration for file system trees between the domain object and the presentation object.
/// </summary>
public class FileSystemTreeMappingConfig : IRegister
{
#region ===================================================================== METHODS ===================================================================================
/// <summary>
/// Registers the mapping configuration.
/// </summary>
/// <param name="config">The type adapter configuration.</param>
public void Register(TypeAdapterConfig config)
{
config.NewConfig<WindowsRootItem, FileSystemTreeNodeResponse>()
.Map(dest => dest.Path, src => src.Id.Path)
.Map(dest => dest.Name, src => src.Name)
.Map(dest => dest.ItemType, src => FileSystemItemType.Root)
.Map(dest => dest.IsExpanded, () => false);
config.NewConfig<FileSystemTreeNodeResponse, WindowsRootItem>()
.MapWith(src => WindowsRootItem.Create(
src.Path,
src.Name,
FileSystemItemStatus.Accessible)
.Value);
config.NewConfig<UnixRootItem, FileSystemTreeNodeResponse>()
.Map(dest => dest.Path, src => src.Id.Path)
.Map(dest => dest.Name, src => src.Name)
.Map(dest => dest.ItemType, src => FileSystemItemType.Root)
.Map(dest => dest.IsExpanded, () => false);
config.NewConfig<FileSystemTreeNodeResponse, UnixRootItem>()
.MapWith(src => UnixRootItem.Create(
FileSystemItemStatus.Accessible)
.Value);
config.NewConfig<FileSystemItem, FileSystemTreeNodeResponse>()
.MapWith(src => new FileSystemTreeNodeResponse
{
Path = src.Id.Path,
Name = src.Name,
ItemType = src.Type,
IsExpanded = false,
ChildrenLoaded = false,
Children = new List<FileSystemTreeNodeResponse>()
});
}
#endregion
}
@@ -0,0 +1,26 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Contracts.Responses.FileManagement;
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.ValueObjects;
using Mapster;
#endregion
namespace Lumina.Application.Common.Mapping.FileManagement;
/// <summary>
/// Mapping configuration for file system paths between the domain object and the presentation object.
/// </summary>
public class PathSegmentMappingConfig : IRegister
{
#region ===================================================================== METHODS ===================================================================================
/// <summary>
/// Registers the mapping configuration.
/// </summary>
/// <param name="config">The type adapter configuration.</param>
public void Register(TypeAdapterConfig config)
{
config.NewConfig<PathSegment, PathSegmentResponse>()
.Map(dest => dest.Path, src => src.Name)
.MapToConstructor(true);
}
#endregion
}
@@ -1,6 +1,6 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Common.Models.Books;
using Lumina.Domain.Common.Enums;
using Lumina.Contracts.Enums.BookLibrary;
using Lumina.Contracts.Models.WrittenContentLibrary.BookLibrary;
using Lumina.Domain.Common.Primitives;
using Lumina.Domain.Common.ValueObjects.Metadata;
using Lumina.Domain.Core.Aggregates.MediaContributor.MediaContributorAggregate.ValueObjects;
@@ -8,6 +8,9 @@ using Lumina.Domain.Core.Aggregates.WrittenContentLibrary.BookLibraryAggregate;
using Lumina.Domain.Core.Aggregates.WrittenContentLibrary.BookLibraryAggregate.Entities;
using Lumina.Domain.Core.Aggregates.WrittenContentLibrary.BookLibraryAggregate.ValueObjects;
using Mapster;
using System;
using System.Collections.Generic;
using System.Linq;
#endregion
namespace Lumina.Application.Common.Mapping.WrittenContentLibrary.BookLibrary;
@@ -24,7 +27,7 @@ public class BookMappingConfig : IRegister
/// <param name="config">The type adapter configuration.</param>
public void Register(TypeAdapterConfig config)
{
config.NewConfig<Book, BookDto>()
config.NewConfig<Book, BookModel>()
.Map(dest => dest.Id, src => src.Id.Value)
.Map(dest => dest.Title, src => src.Metadata.Title)
.Map(dest => dest.OriginalTitle, src => src.Metadata.OriginalTitle.HasValue ? src.Metadata.OriginalTitle.Value : default)
@@ -62,7 +65,7 @@ public class BookMappingConfig : IRegister
.Map(dest => dest.Created, src => src.Created)
.Map(dest => dest.Updated, src => src.Updated.HasValue ? src.Updated : null);
config.NewConfig<BookRating, BookRatingDto>()
config.NewConfig<BookRating, BookRatingModel>()
.Map(dest => dest.Value, src => src.Value)
.Map(dest => dest.MaxValue, src => src.MaxValue)
.Map(dest => dest.VoteCount, src => src.VoteCount.HasValue ? src.VoteCount.Value : default)
@@ -71,8 +74,8 @@ public class BookMappingConfig : IRegister
config.NewConfig<Optional<BookRatingSource>, BookRatingSource?>()
.MapWith(src => src.HasValue ? src.Value : default);
// from BookDto to Book
config.NewConfig<BookDto, Book>()
// from BookModel to Book
config.NewConfig<BookModel, Book>()
.MapWith(src => Book.Create(
BookId.Create(src.Id),
WrittenContentMetadata.Create(
@@ -1,201 +0,0 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Common.Models.Common;
#endregion
namespace Lumina.Application.Common.Models.Books;
/// <summary>
/// Represents a book.
/// </summary>
public class BookDto : IStorageEntity
{
#region ==================================================================== PROPERTIES =================================================================================
public Guid Id { get; init; }
/// <summary>
/// Gets the title of the media item.
/// </summary>
public string Title { get; init; } = null!;
/// <summary>
/// Gets the original title of the media item.
/// </summary>
public string? OriginalTitle { get; init; }
/// <summary>
/// Gets the optional description of the media item.
/// </summary>
public string? Description { get; init; }
/// <summary>
/// Gets the optional original release date of the media item.
/// </summary>
public DateOnly? OriginalReleaseDate { get; init; }
/// <summary>
/// Gets the optional original release year of the media item.
/// This is useful when only the year of original release is known.
/// </summary>
public int? OriginalReleaseYear { get; init; }
/// <summary>
/// Gets the optional re-release or reissue date of the media item.
/// </summary>
public DateOnly? ReReleaseDate { get; init; }
/// <summary>
/// Gets the optional re-release or reissue year of the media item.
/// </summary>
public int? ReReleaseYear { get; init; }
/// <summary>
/// Gets the optional country or region of release.
/// </summary>
public string? ReleaseCountry { get; init; }
/// <summary>
/// Gets the optional release version or edition. (e.g. "Original", "Director's Cut", "2.0")
/// </summary>
public string? ReleaseVersion { get; init; }
/// <summary>
/// Gets the ISO 639-1 two-letter language code.
/// </summary>
public string? LanguageCode { get; init; }
/// <summary>
/// Gets the full name of the language in English.
/// </summary>
public string? LanguageName { get; init; }
/// <summary>
/// Gets an optional native name of the language.
/// </summary>
public string? LanguageNativeName { get; init; }
/// <summary>
/// Gets the optional ISO 639-1 two-letter original language code.
/// </summary>
public string? OriginalLanguageCode { get; init; }
/// <summary>
/// Gets the optional full name of the original language in English.
/// </summary>
public string? OriginalLanguageName { get; init; }
/// <summary>
/// Gets an optional native name of the original language.
/// </summary>
public string? OriginalLanguageNativeName { get; init; }
/// <summary>
/// Gets the list of tags associated with the media item.
/// </summary>
public HashSet<TagDto> Tags { get; set; } = [];
/// <summary>
/// Gets the list of genres associated with the media item.
/// </summary>
public HashSet<GenreDto> Genres { get; set; } = [];
/// <summary>
/// Gets the publisher of the written content.
/// </summary>
public string? Publisher { get; init; }
/// <summary>
/// Gets the number of pages in the written content.
/// </summary>
public int? PageCount { get; init; }
/// <summary>
/// Gets the format of the book (e.g., Hardcover, Paperback), if applicable.
/// </summary>
public string Format { get; init; } = null!;
/// <summary>
/// Gets the edition of the book, if applicable.
/// </summary>
public string? Edition { get; init; }
/// <summary>
/// Gets the volume or book number in the series, if applicable.
/// </summary>
public int? VolumeNumber { get; init; }
/// <summary>
/// Gets the series id, if the book is part of a series.
/// </summary>
//public Guid? BookSeriesId { get; init; } = null;
/// <summary>
/// Gets the ASIN (Amazon Standard Identification Number) of the book.
/// </summary>
public string? ASIN { get; init; } = null!;
/// <summary>
/// Gets the Goodreads ID of the book.
/// </summary>
public string? GoodreadsId { get; init; } = null!;
/// <summary>
/// Gets the Library of Congress Control Number (LCCN) of the book.
/// </summary>
public string? LCCN { get; init; } = null!;
/// <summary>
/// Gets the OCLC Number (WorldCat identifier) of the book.
/// </summary>
public string? OCLCNumber { get; init; } = null!;
/// <summary>
/// Gets the Open Library ID of the book.
/// </summary>
public string? OpenLibraryId { get; init; } = null!;
/// <summary>
/// Gets the LibraryThing ID of the book.
/// </summary>
public string? LibraryThingId { get; init; } = null!;
/// <summary>
/// Gets the Google Books ID of the book.
/// </summary>
public string? GoogleBooksId { get; init; } = null!;
/// <summary>
/// Gets the Barnes & Noble ID of the book.
/// </summary>
public string? BarnesAndNobleId { get; init; } = null!;
/// <summary>
/// Gets the Apple Books ID of the book.
/// </summary>
public string? AppleBooksId { get; init; } = null!;
/// <summary>
/// Gets the list of ISBN (International Standard Book Number) of the book.
/// </summary>
public List<IsbnDto> ISBNs { get; set; } = [];
/// <summary>
/// Gets the list of media contributors (actors, directors, etc) starring in this book.
/// </summary>
//public List<ContributorIdDto> ContributorIds { get; init; } = [];
/// <summary>
/// Gets the list of ratings for this book.
/// </summary>
public List<BookRatingDto> Ratings { get; init; } = [];
/// <summary>
/// Gets the time and date when the entity was added.
/// </summary>
public DateTime Created { get; set; }
/// <summary>
/// Gets the optional time and date when the entity was updated.
/// </summary>
public DateTime? Updated { get; set; }
#endregion
}
@@ -1,16 +0,0 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Common.Models.Common;
using Lumina.Domain.Common.Enums;
#endregion
namespace Lumina.Application.Common.Models.Books;
/// <summary>
/// Represents a book rating.
/// </summary>
public record BookRatingDto(
decimal? Value,
decimal? MaxValue,
BookRatingSource? Source,
int? VoteCount
) : RatingDto(Value, MaxValue, VoteCount);
@@ -1,8 +0,0 @@
namespace Lumina.Application.Common.Models.Books;
/// <summary>
/// Represents a request to get book series information.
/// </summary>
public record BookSeriesDto(
string? Title
);
@@ -1,13 +0,0 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Common.Enums;
#endregion
namespace Lumina.Application.Common.Models.Books;
/// <summary>
/// Represents a request to get ISBN information.
/// </summary>
public record IsbnDto(
string? Value,
IsbnFormat? Format
);
@@ -1,21 +0,0 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Common.Models.Common;
#endregion
namespace Lumina.Application.Common.Models.Books;
/// <summary>
/// Represents written content metadata.
/// </summary>
public record WrittenContentMetadataDto(
string? Title,
string? OriginalTitle,
string? Description,
ReleaseInfoDto? ReleaseInfo,
List<GenreDto>? Genres,
List<TagDto>? Tags,
LanguageInfoDto? Language,
LanguageInfoDto? OriginalLanguage,
string? Publisher,
int? PageCount
);
@@ -1,8 +0,0 @@
namespace Lumina.Application.Common.Models.Common;
/// <summary>
/// Represents a request to get genre information.
/// </summary>
public record GenreDto(
string? Name
);
@@ -1,24 +0,0 @@
namespace Lumina.Application.Common.Models.Common;
/// <summary>
/// Interface for storage DTOs, enforces Id.
/// </summary>
public interface IStorageEntity
{
#region ==================================================================== PROPERTIES =================================================================================
/// <summary>
/// Gets or sets the identifier of the entity.
/// </summary>
Guid Id { get; init; }
/// <summary>
/// The time and date when the entity was added.
/// </summary>
DateTime Created { get; set; }
/// <summary>
/// The time and date when the entity was updated.
/// </summary>
DateTime? Updated { get; set; }
#endregion
}
@@ -1,10 +0,0 @@
namespace Lumina.Application.Common.Models.Common;
/// <summary>
/// Represents a request to get language information.
/// </summary>
public record LanguageInfoDto(
string? LanguageCode,
string? LanguageName,
string? NativeName
);
@@ -1,10 +0,0 @@
namespace Lumina.Application.Common.Models.Common;
/// <summary>
/// Represents a rating.
/// </summary>
public abstract record RatingDto(
decimal? Value,
decimal? MaxValue,
int? VoteCount
);
@@ -1,13 +0,0 @@
namespace Lumina.Application.Common.Models.Common;
/// <summary>
/// Represents a request to get release information.
/// </summary>
public record ReleaseInfoDto(
DateOnly? OriginalReleaseDate,
int? OriginalReleaseYear,
DateOnly? ReReleaseDate,
int? ReReleaseYear,
string? ReleaseCountry,
string? ReleaseVersion
);
@@ -1,8 +0,0 @@
namespace Lumina.Application.Common.Models.Common;
/// <summary>
/// Represents a request to get tag information.
/// </summary>
public record TagDto(
string? Name
);
@@ -1,9 +0,0 @@
namespace Lumina.Application.Common.Models.Contributors;
/// <summary>
/// Represents a media contributor.
/// </summary>
public record MediaContributorDto(
MediaContributorNameDto? Name,
MediaContributorRoleDto? Role
);
@@ -1,9 +0,0 @@
namespace Lumina.Application.Common.Models.Contributors;
/// <summary>
/// Represents a media contributor name.
/// </summary>
public record MediaContributorNameDto(
string? DisplayName,
string? LegalName
);
@@ -1,9 +0,0 @@
namespace Lumina.Application.Common.Models.Contributors;
/// <summary>
/// Represents a media contributor role.
/// </summary>
public record MediaContributorRoleDto(
string? Name,
string? Category
);