mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-01 18:57:24 +00:00
Replaces MVC with FastEndpoints in Lumina.Presentation.Api
This commit is contained in:
1 parent
b1a20716df
commit
c7b8bc2f1c
519 files changed
+15329
-8539
No files matched your search
File renamed without changes.
@@ -121,7 +121,7 @@
|
||||
- PhotoLibrary (root: PhotoLibrary, entities: Photo, PhotoAlbum, AlbumArtwork, MoviePoster)
|
||||
- UserProfile (root: User, entities: Playlist, Collection)
|
||||
- SupplementaryContentLibrary (root: SupplementaryContentLibrary, entities: SubtitleFile, Lyrics, LanguageTrack)
|
||||
- FileManagement (root: File, entities: Stream)
|
||||
- FileSystemManagement (root: File, entities: Stream)
|
||||
|
||||
- WrittenContentLibrary
|
||||
- BookLibrary (root: BookLibrary)
|
||||
@@ -219,7 +219,7 @@
|
||||
- Aggregates: UserProfile
|
||||
- Services: RecommendationEngine, ContentCurationService, UserActivityTrackingService
|
||||
- ContentDelivery
|
||||
- Aggregates: FileManagement
|
||||
- Aggregates: FileSystemManagement
|
||||
- Services: StreamingService, ContentSynchronizationService
|
||||
- MetadataManagement
|
||||
- Aggregates: SupplementaryContentLibrary
|
||||
|
||||
@@ -3,7 +3,6 @@ using ErrorOr;
|
||||
using FluentValidation;
|
||||
using Mediator;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
@@ -51,4 +50,4 @@ public class ValidationBehavior<TRequest, TResponse> : IPipelineBehavior<TReques
|
||||
// this is acceptable because we DO know that we will always have a list of errors of type ErrorOr (check the generic constraint at the top of the class!)
|
||||
return (dynamic)errors;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using System;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Converters;
|
||||
|
||||
/// <summary>
|
||||
/// Converts an <see cref="Optional{TValue}"/> to and from JSON.
|
||||
/// </summary>
|
||||
/// <typeparam name="TValue">The type of the value represented by the <see cref="Optional{TValue}"/> structure.</typeparam>
|
||||
public class OptionalJsonConverter<TValue> : JsonConverter<Optional<TValue>>
|
||||
{
|
||||
/// <summary>
|
||||
/// 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{TValue}"/> value.</returns>
|
||||
public override Optional<TValue> Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||
{
|
||||
if (reader.TokenType == JsonTokenType.Null)
|
||||
return Optional<TValue>.None();
|
||||
TValue? value = JsonSerializer.Deserialize<TValue>(ref reader, options);
|
||||
return Optional<TValue>.Some(value!);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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<TValue> value, JsonSerializerOptions options)
|
||||
{
|
||||
if (value.HasValue)
|
||||
JsonSerializer.Serialize(writer, value.Value, options);
|
||||
else
|
||||
writer.WriteNullValue();
|
||||
}
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using System;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Converters;
|
||||
|
||||
/// <summary>
|
||||
/// A factory for creating <see cref="OptionalJsonConverter{T}"/> instances.
|
||||
/// </summary>
|
||||
public class OptionalJsonConverterFactory : JsonConverterFactory
|
||||
{
|
||||
/// <summary>
|
||||
/// 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{TValue}"/>, <see langword="false"/> otherwise.</returns>
|
||||
public override bool CanConvert(Type typeToConvert)
|
||||
{
|
||||
return typeToConvert.IsGenericType && typeToConvert.GetGenericTypeDefinition() == typeof(Optional<>);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a converter for the specified type.
|
||||
/// </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{TValue}"/>.</returns>
|
||||
public override JsonConverter CreateConverter(Type typeToConvert, JsonSerializerOptions options)
|
||||
{
|
||||
Type valueType = typeToConvert.GetGenericArguments()[0];
|
||||
JsonConverter converter = (JsonConverter)Activator.CreateInstance(
|
||||
typeof(OptionalJsonConverter<>).MakeGenericType(valueType))!;
|
||||
return converter;
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,8 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DataAccess.Repositories.Common.Actions;
|
||||
using Lumina.Application.Common.DataAccess.Repositories.Common.Base;
|
||||
using Lumina.Contracts.Models.WrittenContentLibrary.BookLibrary;
|
||||
using Lumina.Contracts.Entities.WrittenContentLibrary.BookLibrary;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.DataAccess.Repositories.Books;
|
||||
@@ -9,8 +10,8 @@ namespace Lumina.Application.Common.DataAccess.Repositories.Books;
|
||||
/// <summary>
|
||||
/// Interface for the repository for books.
|
||||
/// </summary>
|
||||
public interface IBookRepository : IRepository<BookModel>,
|
||||
IInsertRepositoryAction<BookModel>,
|
||||
IGetAllRepositoryAction<BookModel>
|
||||
public interface IBookRepository : IRepository<BookEntity>,
|
||||
IInsertRepositoryAction<BookEntity>,
|
||||
IGetAllRepositoryAction<BookEntity>
|
||||
{
|
||||
}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Contracts.Models.Common;
|
||||
using Lumina.Contracts.Entities.Common;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Contracts.Models.Common;
|
||||
using Lumina.Contracts.Entities.Common;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Contracts.Models.Common;
|
||||
using Lumina.Contracts.Entities.Common;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Contracts.Models.Common;
|
||||
using Lumina.Contracts.Entities.Common;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.Models.Common;
|
||||
using Lumina.Contracts.Entities.Common;
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FluentValidation;
|
||||
using Lumina.Application.Common.Behaviors;
|
||||
using Mapster;
|
||||
using MapsterMapper;
|
||||
using Mediator;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
#endregion
|
||||
@@ -33,12 +31,6 @@ public static class ApplicationLayerServices
|
||||
// register fluent validators
|
||||
services.AddValidatorsFromAssembly(typeof(ApplicationLayerServices).Assembly);
|
||||
|
||||
// register mapster configs in this assembly
|
||||
TypeAdapterConfig mapsterConfig = TypeAdapterConfig.GlobalSettings;
|
||||
mapsterConfig.Scan(typeof(ApplicationLayerServices).Assembly);
|
||||
services.AddSingleton(mapsterConfig);
|
||||
services.AddScoped<IMapper, ServiceMapper>();
|
||||
|
||||
return services;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.Entities.Common;
|
||||
using Lumina.Domain.Common.ValueObjects.Metadata;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.Common.Metadata;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="Genre"/>.
|
||||
/// </summary>
|
||||
public static class GenreMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="domainModel"/> to <see cref="GenreEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="domainModel">The domain model to be converted.</param>
|
||||
/// <returns>The converted repository entity.</returns>
|
||||
public static GenreEntity ToRepositoryEntity(this Genre domainModel)
|
||||
{
|
||||
return new GenreEntity(
|
||||
domainModel.Name
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts <paramref name="domainModels"/> to a collection of <see cref="GenreEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="domainModels">The domain models to be converted.</param>
|
||||
/// <returns>The converted repository entities.</returns>
|
||||
public static IEnumerable<GenreEntity> ToRepositoryEntities(this IEnumerable<Genre> domainModels)
|
||||
{
|
||||
return domainModels.Select(domainModel => domainModel.ToRepositoryEntity());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Contracts.Entities.Common;
|
||||
using Lumina.Domain.Common.ValueObjects.Metadata;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.Common.Metadata;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="GenreEntity"/>.
|
||||
/// </summary>
|
||||
public static class GenreModelMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="repositoryEntity"/> to <see cref="GenreEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="repositoryEntity">The repository model to be converted.</param>
|
||||
/// <returns>The converted domain model.</returns>
|
||||
public static ErrorOr<Genre> ToDomainModel(this GenreEntity repositoryEntity)
|
||||
{
|
||||
return Genre.Create(
|
||||
repositoryEntity.Name
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts <paramref name="repositoryEntities"/> to a collection of <see cref="Genre"/>.
|
||||
/// </summary>
|
||||
/// <param name="repositoryEntities">The repository models to be converted.</param>
|
||||
/// <returns>The converted domain models.</returns>
|
||||
public static IEnumerable<ErrorOr<Genre>> ToDomainModels(this IEnumerable<GenreEntity> repositoryEntities)
|
||||
{
|
||||
return repositoryEntities.Select(repositoryEntity => repositoryEntity.ToDomainModel());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.Entities.Common;
|
||||
using Lumina.Domain.Common.ValueObjects.Metadata;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.Common.Metadata;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="Tag"/>.
|
||||
/// </summary>
|
||||
public static class TagMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="domainModel"/> to <see cref="TagEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="domainModel">The domain model to be converted.</param>
|
||||
/// <returns>The converted repository entity.</returns>
|
||||
public static TagEntity ToRepositoryEntity(this Tag domainModel)
|
||||
{
|
||||
return new TagEntity(
|
||||
domainModel.Name
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts <paramref name="domainModels"/> to a collection of <see cref="TagEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="domainModels">The domain model to be converted.</param>
|
||||
/// <returns>The converted repository entities.</returns>
|
||||
public static IEnumerable<TagEntity> ToRepositoryEntities(this IEnumerable<Tag> domainModels)
|
||||
{
|
||||
return domainModels.Select(domainModel => domainModel.ToRepositoryEntity());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Contracts.Entities.Common;
|
||||
using Lumina.Domain.Common.ValueObjects.Metadata;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.Common.Metadata;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="TagEntity"/>.
|
||||
/// </summary>
|
||||
public static class TagModelMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="repositoryEntity"/> to <see cref="Tag"/>.
|
||||
/// </summary>
|
||||
/// <param name="repositoryEntity">The repository entity to be converted.</param>
|
||||
/// <returns>The converted domain model.</returns>
|
||||
public static ErrorOr<Tag> ToDomainModel(this TagEntity repositoryEntity)
|
||||
{
|
||||
return Tag.Create(
|
||||
repositoryEntity.Name
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts <paramref name="repositoryEntities"/> to a collection of <see cref="Tag"/>.
|
||||
/// </summary>
|
||||
/// <param name="repositoryEntities">The repository entities to be converted.</param>
|
||||
/// <returns>The converted domain models.</returns>
|
||||
public static IEnumerable<ErrorOr<Tag>> ToDomainModels(this IEnumerable<TagEntity> repositoryEntities)
|
||||
{
|
||||
return repositoryEntities.Select(domainModel => domainModel.ToDomainModel());
|
||||
}
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.Models.FileManagement;
|
||||
using Lumina.Contracts.Responses.FileManagement;
|
||||
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate;
|
||||
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Entities;
|
||||
using Mapster;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
#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
|
||||
{
|
||||
/// <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.Adapt<List<FileSystemTreeNodeResponse>>())
|
||||
.MapToConstructor(true);
|
||||
|
||||
config.NewConfig<Directory, DirectoryResponse>()
|
||||
.MapWith(src => new DirectoryResponse(
|
||||
src.Id.Path,
|
||||
src.Name,
|
||||
src.DateCreated.Value,
|
||||
src.DateModified.Value,
|
||||
src.Items.Adapt<List<FileSystemItemModel>>()
|
||||
));
|
||||
|
||||
config.NewConfig<FileSystemItem, FileSystemItemModel>()
|
||||
.MapWith(src => new FileSystemItemModel(
|
||||
src.Id.Path,
|
||||
src.Name,
|
||||
DateTime.Now,
|
||||
DateTime.Now
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
#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
|
||||
{
|
||||
/// <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);
|
||||
|
||||
config.NewConfig<File, FileResponse>()
|
||||
.MapWith(src => new FileResponse(
|
||||
src.Id.Path,
|
||||
src.Name,
|
||||
src.DateCreated.HasValue ? src.DateCreated.Value : default,
|
||||
src.DateModified.HasValue ? src.DateModified.Value : default,
|
||||
src.Size
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -1,65 +0,0 @@
|
||||
#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;
|
||||
using System.Linq;
|
||||
#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
|
||||
{
|
||||
/// <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)
|
||||
.Map(dest => dest.ChildrenLoaded, () => false)
|
||||
.Map(dest => dest.Children, src => src.Items.Select(item => item.Adapt<FileSystemTreeNodeResponse>(config)).ToList());
|
||||
|
||||
config.NewConfig<FileSystemTreeNodeResponse, UnixRootItem>()
|
||||
.MapWith(src => UnixRootItem.Create(
|
||||
FileSystemItemStatus.Accessible)
|
||||
.Value);
|
||||
|
||||
config.NewConfig<FileSystemItem, 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.ChildrenLoaded, _ => false)
|
||||
.AfterMapping((src, dest) =>
|
||||
{
|
||||
if (src is Directory dir)
|
||||
dest.Children = dir.Items.Select(item => item.Adapt<FileSystemTreeNodeResponse>(config)).ToList();
|
||||
else
|
||||
dest.Children = [];
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
#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
|
||||
{
|
||||
/// <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);
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
#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 thumbnails between the domain object and the presentation object.
|
||||
/// </summary>
|
||||
public class ThumbnailMappingConfig : IRegister
|
||||
{
|
||||
/// <summary>
|
||||
/// Registers the mapping configuration.
|
||||
/// </summary>
|
||||
/// <param name="config">The type adapter configuration.</param>
|
||||
public void Register(TypeAdapterConfig config)
|
||||
{
|
||||
config.NewConfig<Thumbnail, ThumbnailResponse>()
|
||||
.Map(dest => dest.Type, src => src.Type)
|
||||
.Map(dest => dest.Bytes, src => src.Bytes)
|
||||
.MapToConstructor(true);
|
||||
}
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Contracts.Enums.FileSystem;
|
||||
using Lumina.Contracts.Responses.FileSystemManagement.Common;
|
||||
using Lumina.Domain.Core.Aggregates.FileSystemManagement.FileSystemManagementAggregate.Entities;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.FileSystemManagement.Common;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="FileSystemTreeNodeResponse"/>.
|
||||
/// </summary>
|
||||
public static class FileSystemTreeNodeResponseMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="response"/> to <see cref="WindowsRootItem"/>.
|
||||
/// </summary>
|
||||
/// <param name="response">The response to be converted.</param>
|
||||
/// <returns>The converted domain model.</returns>
|
||||
public static ErrorOr<WindowsRootItem> ToWindowsRootItem(this FileSystemTreeNodeResponse response)
|
||||
{
|
||||
return WindowsRootItem.Create(
|
||||
response.Path,
|
||||
response.Name,
|
||||
FileSystemItemStatus.Accessible
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts <paramref name="_"/> to <see cref="UnixRootItem"/>.
|
||||
/// </summary>
|
||||
/// <param name="_">The response to be converted.</param>
|
||||
/// <returns>The converted domain model.</returns>
|
||||
public static ErrorOr<UnixRootItem> ToUnixRootItem(this FileSystemTreeNodeResponse _)
|
||||
{
|
||||
return UnixRootItem.Create(
|
||||
FileSystemItemStatus.Accessible
|
||||
);
|
||||
}
|
||||
}
|
||||
+72
@@ -0,0 +1,72 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.Mapping.FileSystemManagement.FileSystem;
|
||||
using Lumina.Contracts.Responses.FileSystemManagement.Common;
|
||||
using Lumina.Contracts.Responses.FileSystemManagement.Directories;
|
||||
using Lumina.Domain.Core.Aggregates.FileSystemManagement.FileSystemManagementAggregate.Entities;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.FileSystemManagement.Directories;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="Directory"/>.
|
||||
/// </summary>
|
||||
public static class DirectoryMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="domainModel"/> to <see cref="FileSystemTreeNodeResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="domainModel">The domain model to be converted.</param>
|
||||
/// <returns>The converted response.</returns>
|
||||
public static FileSystemTreeNodeResponse ToFileSystemTreeNodeResponse(this Directory domainModel)
|
||||
{
|
||||
return new FileSystemTreeNodeResponse()
|
||||
{
|
||||
Name = domainModel.Name,
|
||||
Path = domainModel.Id.Path,
|
||||
ItemType = domainModel.Type,
|
||||
IsExpanded = false,
|
||||
ChildrenLoaded = false,
|
||||
Children = domainModel.Items.Select(item => item.ToTreeNodeResponse())
|
||||
.ToList()
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts <paramref name="domainModels"/> to a collection of <see cref="FileSystemTreeNodeResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="domainModels">The domain models to be converted.</param>
|
||||
/// <returns>The converted responses.</returns>
|
||||
public static IEnumerable<FileSystemTreeNodeResponse> ToFileSystemTreeNodeResponses(this IEnumerable<Directory> domainModels)
|
||||
{
|
||||
return domainModels.Select(domainModel => domainModel.ToTreeNodeResponse());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts <paramref name="domainModel"/> to <see cref="DirectoryResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="domainModel">The domain model to be converted.</param>
|
||||
/// <returns>The converted response.</returns>
|
||||
public static DirectoryResponse ToResponse(this Directory domainModel)
|
||||
{
|
||||
return new DirectoryResponse(
|
||||
domainModel.Id.Path,
|
||||
domainModel.Name,
|
||||
domainModel.DateCreated.Value,
|
||||
domainModel.DateModified.Value,
|
||||
domainModel.Items.Select(fileSystemItem => fileSystemItem.ToFileSystemItemModel())
|
||||
.ToList()
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts <paramref name="domainModels"/> to a collection of <see cref="DirectoryResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="domainModels">The domain models to be converted.</param>
|
||||
/// <returns>The converted responses.</returns>
|
||||
public static IEnumerable<DirectoryResponse> ToResponses(this IEnumerable<Directory> domainModels)
|
||||
{
|
||||
return domainModels.Select(domainModel => domainModel.ToResponse());
|
||||
}
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Core.FileSystemManagement.Directories.Queries.GetDirectories;
|
||||
using Lumina.Contracts.Requests.FileSystemManagement.Directories;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.FileSystemManagement.Directories;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="GetDirectoriesRequest"/>.
|
||||
/// </summary>
|
||||
public static class GetDirectoriesRequestMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="request"/> to <see cref="GetDirectoriesQuery"/>.
|
||||
/// </summary>
|
||||
/// <param name="request">The request to be converted.</param>
|
||||
/// <returns>The converted query.</returns>
|
||||
public static GetDirectoriesQuery ToQuery(this GetDirectoriesRequest request)
|
||||
{
|
||||
return new GetDirectoriesQuery(request.Path, request.IncludeHiddenElements);
|
||||
}
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Core.FileSystemManagement.Directories.Queries.GetDirectoryTree;
|
||||
using Lumina.Contracts.Requests.FileSystemManagement.Directories;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.FileSystemManagement.Directories;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="GetDirectoryTreeRequest"/>.
|
||||
/// </summary>
|
||||
public static class GetDirectoryTreeRequestMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="request"/> to <see cref="GetDirectoryTreeQuery"/>.
|
||||
/// </summary>
|
||||
/// <param name="request">The request to be converted.</param>
|
||||
/// <returns>The converted query.</returns>
|
||||
public static GetDirectoryTreeQuery ToQuery(this GetDirectoryTreeRequest request)
|
||||
{
|
||||
return new GetDirectoryTreeQuery(request.Path, request.IncludeFiles, request.IncludeHiddenElements);
|
||||
}
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Core.FileSystemManagement.Directories.Queries.GetTreeDirectories;
|
||||
using Lumina.Contracts.Requests.FileSystemManagement.Directories;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.FileSystemManagement.Directories;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="GetTreeDirectoriesRequest"/>.
|
||||
/// </summary>
|
||||
public static class GetTreeDirectoriesRequestMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="request"/> to <see cref="GetTreeDirectoriesQuery"/>.
|
||||
/// </summary>
|
||||
/// <param name="request">The request to be converted.</param>
|
||||
/// <returns>The converted query.</returns>
|
||||
public static GetTreeDirectoriesQuery ToQuery(this GetTreeDirectoriesRequest request)
|
||||
{
|
||||
return new GetTreeDirectoriesQuery(request.Path, request.IncludeHiddenElements);
|
||||
}
|
||||
}
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.Mapping.FileSystemManagement.Directories;
|
||||
using Lumina.Application.Common.Mapping.FileSystemManagement.Files;
|
||||
using Lumina.Contracts.Entities.FileSystemManagement;
|
||||
using Lumina.Contracts.Responses.FileSystemManagement.Common;
|
||||
using Lumina.Domain.Core.Aggregates.FileSystemManagement.FileSystemManagementAggregate;
|
||||
using Lumina.Domain.Core.Aggregates.FileSystemManagement.FileSystemManagementAggregate.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.FileSystemManagement.FileSystem;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="FileSystemItem"/>.
|
||||
/// </summary>
|
||||
public static class FileSystemItemMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="domainModel"/> to <see cref="FileSystemItemEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="domainModel">The domain model to be converted.</param>
|
||||
/// <returns>The converted model.</returns>
|
||||
public static FileSystemItemEntity ToFileSystemItemModel(this FileSystemItem domainModel)
|
||||
{
|
||||
return new FileSystemItemEntity(
|
||||
domainModel.Id.Path,
|
||||
domainModel.Name,
|
||||
DateTime.Now,
|
||||
DateTime.Now
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts <paramref name="domainModel"/> to <see cref="FileSystemTreeNodeResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="domainModel">The domain model to be converted.</param>
|
||||
/// <returns>The converted model.</returns>
|
||||
/// <exception cref="ArgumentException">Thrown when the provided parameter is not an expected descendant of <see cref="FileSystemItem"/>.</exception>
|
||||
public static FileSystemTreeNodeResponse ToTreeNodeResponse(this FileSystemItem domainModel)
|
||||
{
|
||||
if (domainModel is Directory directory)
|
||||
return directory.ToFileSystemTreeNodeResponse();
|
||||
else if (domainModel is File file)
|
||||
return file.ToFileSystemTreeNodeResponse();
|
||||
else if (domainModel is WindowsRootItem windowsRootItem)
|
||||
return windowsRootItem.ToTreeNodeResponse();
|
||||
else if (domainModel is UnixRootItem unixRootItem)
|
||||
return unixRootItem.ToTreeNodeResponse();
|
||||
else
|
||||
throw new ArgumentException("Invalid FileSystemItem");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts <paramref name="domainModels"/> to <see cref="IEnumerable<FileSystemTreeNodeResponse>"/>.
|
||||
/// </summary>
|
||||
/// <param name="domainModels">The domain models to be converted.</param>
|
||||
/// <returns>The converted models.</returns>
|
||||
public static IEnumerable<FileSystemTreeNodeResponse> ToTreeNodeResponses(this IEnumerable<FileSystemItem> domainModels)
|
||||
{
|
||||
return domainModels.Select(domainModel => domainModel.ToTreeNodeResponse());
|
||||
}
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.Enums.FileSystem;
|
||||
using Lumina.Contracts.Responses.FileSystemManagement.Common;
|
||||
using Lumina.Domain.Core.Aggregates.FileSystemManagement.FileSystemManagementAggregate.Entities;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.FileSystemManagement.FileSystem;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="UnixRootItem"/>.
|
||||
/// </summary>
|
||||
public static class UnixRootItemMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="domainModel"/> to <see cref="FileSystemTreeNodeResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="domainModel">The domain model to be converted.</param>
|
||||
/// <returns>The converted response.</returns>
|
||||
public static FileSystemTreeNodeResponse ToTreeNodeResponse(this UnixRootItem domainModel)
|
||||
{
|
||||
return new FileSystemTreeNodeResponse()
|
||||
{
|
||||
Path = domainModel.Id.Path,
|
||||
Name = domainModel.Name,
|
||||
ItemType = FileSystemItemType.Root,
|
||||
IsExpanded = false,
|
||||
ChildrenLoaded = false,
|
||||
Children = domainModel.Items.Select(item => item.ToTreeNodeResponse())
|
||||
.ToList()
|
||||
};
|
||||
}
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.Mapping.FileSystemManagement.Common;
|
||||
using Lumina.Contracts.Enums.FileSystem;
|
||||
using Lumina.Contracts.Responses.FileSystemManagement.Common;
|
||||
using Lumina.Contracts.Responses.FileSystemManagement.Directories;
|
||||
using Lumina.Domain.Core.Aggregates.FileSystemManagement.FileSystemManagementAggregate.Entities;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.FileSystemManagement.FileSystem;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="WindowsRootItem"/>.
|
||||
/// </summary>
|
||||
public static class WindowsRootItemMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="domainModel"/> to <see cref="FileSystemTreeNodeResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="domainModel">The domain model to be converted.</param>
|
||||
/// <returns>The converted response.</returns>
|
||||
public static FileSystemTreeNodeResponse ToTreeNodeResponse(this WindowsRootItem domainModel)
|
||||
{
|
||||
return new FileSystemTreeNodeResponse()
|
||||
{
|
||||
Path = domainModel.Id.Path,
|
||||
Name = domainModel.Name,
|
||||
ItemType = FileSystemItemType.Root,
|
||||
IsExpanded = false
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.Responses.FileSystemManagement.Common;
|
||||
using Lumina.Contracts.Responses.FileSystemManagement.Files;
|
||||
using Lumina.Domain.Core.Aggregates.FileSystemManagement.FileSystemManagementAggregate.Entities;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.FileSystemManagement.Files;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="File"/>.
|
||||
/// </summary>
|
||||
public static class FileMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="domainModel"/> to <see cref="FileSystemTreeNodeResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="domainModel">The domain model to be converted.</param>
|
||||
/// <returns>The converted response.</returns>
|
||||
public static FileSystemTreeNodeResponse ToFileSystemTreeNodeResponse(this File domainModel)
|
||||
{
|
||||
return new FileSystemTreeNodeResponse()
|
||||
{
|
||||
Name = domainModel.Name,
|
||||
Path = domainModel.Id.Path,
|
||||
ItemType = domainModel.Type,
|
||||
IsExpanded = false,
|
||||
ChildrenLoaded = false
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts <paramref name="domainModels"/> to a collection of <see cref="FileSystemTreeNodeResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="domainModels">The domain models to be converted.</param>
|
||||
/// <returns>The converted responses.</returns>
|
||||
public static IEnumerable<FileSystemTreeNodeResponse> ToFileSystemTreeNodeResponses(this IEnumerable<File> domainModels)
|
||||
{
|
||||
return domainModels.Select(domainModel => domainModel.ToFileSystemTreeNodeResponse());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts <paramref name="domainModel"/> to <see cref="FileResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="domainModel">The domain model to be converted.</param>
|
||||
/// <returns>The converted response.</returns>
|
||||
public static FileResponse ToResponse(this File domainModel)
|
||||
{
|
||||
return new FileResponse(
|
||||
domainModel.Id.Path,
|
||||
domainModel.Name,
|
||||
domainModel.DateCreated.HasValue ? domainModel.DateCreated.Value : default,
|
||||
domainModel.DateModified.HasValue ? domainModel.DateModified.Value : default,
|
||||
domainModel.Size
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts <paramref name="domainModels"/> to a collection of <see cref="FileResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="domainModels">The domain models to be converted.</param>
|
||||
/// <returns>The converted responses.</returns>
|
||||
public static IEnumerable<FileResponse> ToResponses(this IEnumerable<File> domainModels)
|
||||
{
|
||||
return domainModels.Select(domainModel => domainModel.ToResponse());
|
||||
}
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Core.FileSystemManagement.Files.Queries.GetFiles;
|
||||
using Lumina.Contracts.Requests.FileSystemManagement.Files;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.FileSystemManagement.Files;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="GetFilesRequest"/>.
|
||||
/// </summary>
|
||||
public static class GetFilesRequestMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="request"/> to <see cref="GetFilesQuery"/>.
|
||||
/// </summary>
|
||||
/// <param name="request">The request to be converted.</param>
|
||||
/// <returns>The converted query.</returns>
|
||||
public static GetFilesQuery ToQuery(this GetFilesRequest request)
|
||||
{
|
||||
return new GetFilesQuery(request.Path, request.IncludeHiddenElements);
|
||||
}
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Core.FileSystemManagement.Directories.Queries.GetTreeDirectories;
|
||||
using Lumina.Application.Core.FileSystemManagement.Files.Queries.GetTreeFiles;
|
||||
using Lumina.Contracts.Requests.FileSystemManagement.Files;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.FileSystemManagement.Files;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="GetTreeFilesRequest"/>.
|
||||
/// </summary>
|
||||
public static class GetTreeFilesRequestMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="request"/> to <see cref="GetTreeDirectoriesQuery"/>.
|
||||
/// </summary>
|
||||
/// <param name="request">The request to be converted.</param>
|
||||
/// <returns>The converted query.</returns>
|
||||
public static GetTreeFilesQuery ToQuery(this GetTreeFilesRequest request)
|
||||
{
|
||||
return new GetTreeFilesQuery(request.Path, request.IncludeHiddenElements);
|
||||
}
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Core.FileSystemManagement.Paths.Queries.CheckPathExists;
|
||||
using Lumina.Contracts.Requests.FileSystemManagement.Path;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.FileSystemManagement.Paths;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="CheckPathExistsRequest"/>.
|
||||
/// </summary>
|
||||
public static class CheckPathExistsQueryMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="request"/> to <see cref="CheckPathExistsQuery"/>.
|
||||
/// </summary>
|
||||
/// <param name="request">The request to be converted.</param>
|
||||
/// <returns>The converted query.</returns>
|
||||
public static CheckPathExistsQuery ToQuery(this CheckPathExistsRequest request)
|
||||
{
|
||||
return new CheckPathExistsQuery(
|
||||
request.Path,
|
||||
request.IncludeHiddenElements
|
||||
);
|
||||
}
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Core.FileSystemManagement.Paths.Commands.CombinePath;
|
||||
using Lumina.Contracts.Requests.FileSystemManagement.Path;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.FileSystemManagement.Paths;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="CombinePathRequest"/>.
|
||||
/// </summary>
|
||||
public static class CombinePathRequestMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="request"/> to <see cref="CombinePathCommand"/>.
|
||||
/// </summary>
|
||||
/// <param name="request">The request to be converted.</param>
|
||||
/// <returns>The converted command.</returns>
|
||||
public static CombinePathCommand ToCommand(this CombinePathRequest request)
|
||||
{
|
||||
return new CombinePathCommand(
|
||||
request.OriginalPath,
|
||||
request.NewPath
|
||||
);
|
||||
}
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Core.FileSystemManagement.Paths.Queries.GetPathParent;
|
||||
using Lumina.Contracts.Requests.FileSystemManagement.Path;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.FileSystemManagement.Paths;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="GetPathParentRequest"/>.
|
||||
/// </summary>
|
||||
public static class GetPathParentRequestMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="request"/> to <see cref="GetPathParentQuery"/>.
|
||||
/// </summary>
|
||||
/// <param name="request">The request to be converted.</param>
|
||||
/// <returns>The converted query.</returns>
|
||||
public static GetPathParentQuery ToQuery(this GetPathParentRequest request)
|
||||
{
|
||||
return new GetPathParentQuery(
|
||||
request.Path
|
||||
);
|
||||
}
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Core.FileSystemManagement.Paths.Queries.GetPathRoot;
|
||||
using Lumina.Contracts.Requests.FileSystemManagement.Path;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.FileSystemManagement.Paths;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="GetPathRootRequest"/>.
|
||||
/// </summary>
|
||||
public static class GetPathRootRequestMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="request"/> to <see cref="GetPathRootQuery"/>.
|
||||
/// </summary>
|
||||
/// <param name="request">The request to be converted.</param>
|
||||
/// <returns>The converted query.</returns>
|
||||
public static GetPathRootQuery ToQuery(this GetPathRootRequest request)
|
||||
{
|
||||
return new GetPathRootQuery(request.Path);
|
||||
}
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.Responses.FileSystemManagement.Path;
|
||||
using Lumina.Domain.Core.Aggregates.FileSystemManagement.FileSystemManagementAggregate.ValueObjects;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.FileSystemManagement.Paths;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="PathSegment"/>.
|
||||
/// </summary>
|
||||
public static class PathSegmentMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="domainModel"/> to <see cref="PathSegmentResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="domainModel">The domain model to be converted.</param>
|
||||
/// <returns>The converted response.</returns>
|
||||
public static PathSegmentResponse ToResponse(this PathSegment domainModel)
|
||||
{
|
||||
return new PathSegmentResponse(
|
||||
domainModel.Name
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts <paramref name="domainModels"/> to a collection of <see cref="PathSegmentResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="domainModels">The domain models to be converted.</param>
|
||||
/// <returns>The converted responses.</returns>
|
||||
public static IEnumerable<PathSegmentResponse> ToResponses(this IEnumerable<PathSegment> domainModels)
|
||||
{
|
||||
return domainModels.Select(domainModel => domainModel.ToResponse());
|
||||
}
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Core.FileSystemManagement.Paths.Commands.SplitPath;
|
||||
using Lumina.Contracts.Requests.FileSystemManagement.Path;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.FileSystemManagement.Paths;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="SplitPathRequest"/>.
|
||||
/// </summary>
|
||||
public static class SplitPathRequestMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="request"/> to <see cref="SplitPathCommand"/>.
|
||||
/// </summary>
|
||||
/// <param name="request">The request to be converted.</param>
|
||||
/// <returns>The converted command.</returns>
|
||||
public static SplitPathCommand ToCommand(this SplitPathRequest request)
|
||||
{
|
||||
return new SplitPathCommand(
|
||||
request.Path
|
||||
);
|
||||
}
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Core.FileSystemManagement.Paths.Queries.ValidatePath;
|
||||
using Lumina.Contracts.Requests.FileSystemManagement.Path;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.FileSystemManagement.Paths;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="ValidatePathRequest"/>.
|
||||
/// </summary>
|
||||
public static class ValidatePathRequestMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="request"/> to <see cref="ValidatePathQuery"/>.
|
||||
/// </summary>
|
||||
/// <param name="request">The request to be converted.</param>
|
||||
/// <returns>The converted query.</returns>
|
||||
public static ValidatePathQuery ToQuery(this ValidatePathRequest request)
|
||||
{
|
||||
return new ValidatePathQuery(
|
||||
request.Path
|
||||
);
|
||||
}
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Core.FileSystemManagement.Thumbnails.Queries.GetThumbnail;
|
||||
using Lumina.Contracts.Requests.FileSystemManagement.Thumbnails;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.FileSystemManagement.Thumbnails;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="GetThumbnailRequest"/>.
|
||||
/// </summary>
|
||||
public static class GetThumbnailRequestMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="request"/> to <see cref="GetThumbnailQuery"/>.
|
||||
/// </summary>
|
||||
/// <param name="request">The request to be converted.</param>
|
||||
/// <returns>The converted query.</returns>
|
||||
public static GetThumbnailQuery ToQuery(this GetThumbnailRequest request)
|
||||
{
|
||||
return new GetThumbnailQuery(request.Path, request.Quality);
|
||||
}
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.Responses.FileSystemManagement.Thumbnails;
|
||||
using Lumina.Domain.Core.Aggregates.FileSystemManagement.FileSystemManagementAggregate.ValueObjects;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.FileSystemManagement.Thumbnails;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="Thumbnail"/>.
|
||||
/// </summary>
|
||||
public static class ThumbnailMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="domainModel"/> to <see cref="ThumbnailResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="domainModel">The domain model to be converted.</param>
|
||||
/// <returns>The converted response.</returns>
|
||||
public static ThumbnailResponse ToResponse(this Thumbnail domainModel)
|
||||
{
|
||||
return new ThumbnailResponse(
|
||||
domainModel.Type,
|
||||
domainModel.Bytes
|
||||
);
|
||||
}
|
||||
}
|
||||
-132
@@ -1,132 +0,0 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
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;
|
||||
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;
|
||||
|
||||
/// <summary>
|
||||
/// Mapping configuration for books between the domain object and the persistence object.
|
||||
/// </summary>
|
||||
public class BookMappingConfig : IRegister
|
||||
{
|
||||
/// <summary>
|
||||
/// Registers the mapping configuration.
|
||||
/// </summary>
|
||||
/// <param name="config">The type adapter configuration.</param>
|
||||
public void Register(TypeAdapterConfig config)
|
||||
{
|
||||
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)
|
||||
.Map(dest => dest.Description, src => src.Metadata.Description.HasValue ? src.Metadata.Description.Value : default)
|
||||
.Map(dest => dest.OriginalReleaseDate, src => src.Metadata.ReleaseInfo.OriginalReleaseDate.HasValue ? src.Metadata.ReleaseInfo.OriginalReleaseDate.Value : default)
|
||||
.Map(dest => dest.OriginalReleaseYear, src => src.Metadata.ReleaseInfo.OriginalReleaseYear.HasValue ? src.Metadata.ReleaseInfo.OriginalReleaseYear.Value : default)
|
||||
.Map(dest => dest.ReReleaseDate, src => src.Metadata.ReleaseInfo.ReReleaseDate.HasValue ? src.Metadata.ReleaseInfo.ReReleaseDate.Value : default)
|
||||
.Map(dest => dest.ReReleaseYear, src => src.Metadata.ReleaseInfo.ReReleaseYear.HasValue ? src.Metadata.ReleaseInfo.ReReleaseYear.Value : default)
|
||||
.Map(dest => dest.ReleaseCountry, src => src.Metadata.ReleaseInfo.ReleaseCountry.HasValue ? src.Metadata.ReleaseInfo.ReleaseCountry.Value : default)
|
||||
.Map(dest => dest.ReleaseVersion, src => src.Metadata.ReleaseInfo.ReleaseVersion.HasValue ? src.Metadata.ReleaseInfo.ReleaseVersion.Value : default)
|
||||
.Map(dest => dest.LanguageCode, src => src.Metadata.Language.HasValue ? src.Metadata.Language.Value.LanguageCode : default)
|
||||
.Map(dest => dest.LanguageName, src => src.Metadata.Language.HasValue ? src.Metadata.Language.Value.LanguageName : default)
|
||||
.Map(dest => dest.LanguageNativeName, src => src.Metadata.Language.HasValue ? src.Metadata.Language.Value.NativeName : default)
|
||||
.Map(dest => dest.OriginalLanguageCode, src => src.Metadata.OriginalLanguage.HasValue ? src.Metadata.OriginalLanguage.Value.LanguageCode : default)
|
||||
.Map(dest => dest.OriginalLanguageName, src => src.Metadata.OriginalLanguage.HasValue ? src.Metadata.OriginalLanguage.Value.LanguageName : default)
|
||||
.Map(dest => dest.OriginalLanguageNativeName, src => src.Metadata.OriginalLanguage.HasValue ? src.Metadata.OriginalLanguage.Value.NativeName : default)
|
||||
.Map(dest => dest.Tags, src => src.Metadata.Tags)
|
||||
.Map(dest => dest.Genres, src => src.Metadata.Genres)
|
||||
.Map(dest => dest.Publisher, src => src.Metadata.Publisher.HasValue ? src.Metadata.Publisher.Value : default)
|
||||
.Map(dest => dest.PageCount, src => src.Metadata.PageCount.HasValue ? src.Metadata.PageCount.Value : default)
|
||||
.Map(dest => dest.Format, src => src.Format.ToString())
|
||||
.Map(dest => dest.Edition, src => src.Edition.HasValue ? src.Edition.Value : default)
|
||||
.Map(dest => dest.VolumeNumber, src => src.VolumeNumber.HasValue ? src.VolumeNumber.Value : default)
|
||||
.Map(dest => dest.ASIN, src => src.ASIN.HasValue ? src.ASIN.Value : default)
|
||||
.Map(dest => dest.GoodreadsId, src => src.GoodreadsId.HasValue ? src.GoodreadsId.Value : default)
|
||||
.Map(dest => dest.LCCN, src => src.LCCN.HasValue ? src.LCCN.Value : default)
|
||||
.Map(dest => dest.OCLCNumber, src => src.OCLCNumber.HasValue ? src.OCLCNumber.Value : default)
|
||||
.Map(dest => dest.OpenLibraryId, src => src.OpenLibraryId.HasValue ? src.OpenLibraryId.Value : default)
|
||||
.Map(dest => dest.LibraryThingId, src => src.LibraryThingId.HasValue ? src.LibraryThingId.Value : default)
|
||||
.Map(dest => dest.GoogleBooksId, src => src.GoogleBooksId.HasValue ? src.GoogleBooksId.Value : default)
|
||||
.Map(dest => dest.BarnesAndNobleId, src => src.BarnesAndNobleId.HasValue ? src.BarnesAndNobleId.Value : default)
|
||||
.Map(dest => dest.AppleBooksId, src => src.AppleBooksId.HasValue ? src.AppleBooksId.Value : default)
|
||||
.Map(dest => dest.ISBNs, src => src.ISBNs)
|
||||
.Map(dest => dest.Ratings, src => src.Ratings)
|
||||
.Map(dest => dest.Created, src => src.Created)
|
||||
.Map(dest => dest.Updated, src => src.Updated.HasValue ? src.Updated : null);
|
||||
|
||||
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)
|
||||
.Map(dest => dest.Source, src => src.Source.HasValue ? src.Source.Value : default);
|
||||
|
||||
config.NewConfig<Optional<BookRatingSource>, BookRatingSource?>()
|
||||
.MapWith(src => src.HasValue ? src.Value : default);
|
||||
|
||||
// from BookModel to Book
|
||||
config.NewConfig<BookModel, Book>()
|
||||
.MapWith(src => Book.Create(
|
||||
BookId.Create(src.Id),
|
||||
WrittenContentMetadata.Create(
|
||||
src.Title,
|
||||
Optional<string>.FromNullable(src.OriginalTitle),
|
||||
Optional<string>.FromNullable(src.Description),
|
||||
ReleaseInfo.Create(
|
||||
Optional<DateOnly>.FromNullable(src.OriginalReleaseDate),
|
||||
Optional<int>.FromNullable(src.OriginalReleaseYear),
|
||||
Optional<DateOnly>.FromNullable(src.ReReleaseDate),
|
||||
Optional<int>.FromNullable(src.ReReleaseYear),
|
||||
Optional<string>.FromNullable(src.ReleaseCountry),
|
||||
Optional<string>.FromNullable(src.ReleaseVersion)
|
||||
).Value,
|
||||
src.Genres.Select(g => Genre.Create(g.Name!).Value).ToList(),
|
||||
src.Tags.Select(t => Tag.Create(t.Name!).Value).ToList(),
|
||||
src.LanguageCode != null ? LanguageInfo.Create(
|
||||
src.LanguageCode,
|
||||
src.LanguageName!,
|
||||
Optional<string>.FromNullable(src.LanguageNativeName)
|
||||
).Value : Optional<LanguageInfo>.None(),
|
||||
src.OriginalLanguageCode != null ? LanguageInfo.Create(
|
||||
src.OriginalLanguageCode,
|
||||
src.OriginalLanguageName!,
|
||||
Optional<string>.FromNullable(src.OriginalLanguageNativeName)
|
||||
).Value : Optional<LanguageInfo>.None(),
|
||||
Optional<string>.FromNullable(src.Publisher),
|
||||
Optional<int>.FromNullable(src.PageCount)
|
||||
).Value,
|
||||
Optional<BookFormat>.FromNullable(!string.IsNullOrWhiteSpace(src.Format) ? Enum.Parse<BookFormat>(src.Format) : default),
|
||||
Optional<string>.FromNullable(src.Edition),
|
||||
Optional<int>.FromNullable(src.VolumeNumber),
|
||||
Optional<BookSeries>.None(),
|
||||
Optional<string>.FromNullable(src.ASIN),
|
||||
Optional<string>.FromNullable(src.GoodreadsId),
|
||||
Optional<string>.FromNullable(src.LCCN),
|
||||
Optional<string>.FromNullable(src.OCLCNumber),
|
||||
Optional<string>.FromNullable(src.OpenLibraryId),
|
||||
Optional<string>.FromNullable(src.LibraryThingId),
|
||||
Optional<string>.FromNullable(src.GoogleBooksId),
|
||||
Optional<string>.FromNullable(src.BarnesAndNobleId),
|
||||
Optional<string>.FromNullable(src.AppleBooksId),
|
||||
src.Created,
|
||||
Optional<DateTime>.FromNullable(src.Updated),
|
||||
src.ISBNs.Select(i => Isbn.Create(i.Value!, i.Format ?? default).Value).ToList(),
|
||||
new List<MediaContributorId>(),
|
||||
src.Ratings.Select(r => BookRating.Create(
|
||||
r.Value ?? default,
|
||||
r.MaxValue ?? default,
|
||||
Optional<BookRatingSource>.FromNullable(r.Source),
|
||||
Optional<int>.FromNullable(r.VoteCount)
|
||||
).Value).ToList()
|
||||
).Value);
|
||||
}
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Core.WrittenContentLibrary.BooksLibrary.Books.Commands.AddBook;
|
||||
using Lumina.Contracts.Requests.WrittenContentLibrary.BookLibrary.Books;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.WrittenContentLibrary.BookLibrary.Books;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="AddBookRequest"/>.
|
||||
/// </summary>
|
||||
public static class AddBookRequestMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="request"/> to <see cref="AddBookCommand"/>.
|
||||
/// </summary>
|
||||
/// <param name="request">The request to be converted.</param>
|
||||
/// <returns>The converted command.</returns>
|
||||
public static AddBookCommand ToCommand(this AddBookRequest request)
|
||||
{
|
||||
return new AddBookCommand(
|
||||
request.Metadata,
|
||||
request.Format,
|
||||
request.Edition,
|
||||
request.VolumeNumber,
|
||||
request.Series,
|
||||
request.ASIN,
|
||||
request.GoodreadsId,
|
||||
request.LCCN,
|
||||
request.OCLCNumber,
|
||||
request.OpenLibraryId,
|
||||
request.LibraryThingId,
|
||||
request.GoogleBooksId,
|
||||
request.BarnesAndNobleId,
|
||||
request.AppleBooksId,
|
||||
request.ISBNs,
|
||||
request.Contributors,
|
||||
request.Ratings
|
||||
);
|
||||
}
|
||||
}
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.Mapping.Common.Metadata;
|
||||
using Lumina.Application.Common.Mapping.WrittenContentLibrary.BookLibrary.Common;
|
||||
using Lumina.Contracts.Entities.WrittenContentLibrary.BookLibrary;
|
||||
using Lumina.Contracts.Responses.WrittenContentLibrary.BookLibrary.Books;
|
||||
using Lumina.Domain.Core.Aggregates.WrittenContentLibrary.BookLibraryAggregate;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.WrittenContentLibrary.BookLibrary.Books;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="Book"/>.
|
||||
/// </summary>
|
||||
public static class BookMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="domainModel"/> to <see cref="BookEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="domainModel">The domain model to be converted.</param>
|
||||
/// <returns>The converted repository entity.</returns>
|
||||
public static BookEntity ToRepositoryEntity(this Book domainModel)
|
||||
{
|
||||
return new BookEntity
|
||||
{
|
||||
Id = domainModel.Id.Value,
|
||||
Title = domainModel.Metadata.Title,
|
||||
OriginalTitle = domainModel.Metadata.OriginalTitle.HasValue ? domainModel.Metadata.OriginalTitle.Value : null,
|
||||
Description = domainModel.Metadata.Description.HasValue ? domainModel.Metadata.Description.Value : null,
|
||||
OriginalReleaseDate = domainModel.Metadata.ReleaseInfo.OriginalReleaseDate.HasValue ? domainModel.Metadata.ReleaseInfo.OriginalReleaseDate.Value : null,
|
||||
OriginalReleaseYear = domainModel.Metadata.ReleaseInfo.OriginalReleaseYear.HasValue ? domainModel.Metadata.ReleaseInfo.OriginalReleaseYear.Value : null,
|
||||
ReReleaseDate = domainModel.Metadata.ReleaseInfo.ReReleaseDate.HasValue ? domainModel.Metadata.ReleaseInfo.ReReleaseDate.Value : null,
|
||||
ReReleaseYear = domainModel.Metadata.ReleaseInfo.ReReleaseYear.HasValue ? domainModel.Metadata.ReleaseInfo.ReReleaseYear.Value : null,
|
||||
ReleaseCountry = domainModel.Metadata.ReleaseInfo.ReleaseCountry.HasValue ? domainModel.Metadata.ReleaseInfo.ReleaseCountry.Value : null,
|
||||
ReleaseVersion = domainModel.Metadata.ReleaseInfo.ReleaseVersion.HasValue ? domainModel.Metadata.ReleaseInfo.ReleaseVersion.Value : null,
|
||||
LanguageCode = domainModel.Metadata.Language.HasValue ? domainModel.Metadata.Language.Value.LanguageCode : null,
|
||||
LanguageName = domainModel.Metadata.Language.HasValue ? domainModel.Metadata.Language.Value.LanguageName : null,
|
||||
LanguageNativeName = domainModel.Metadata.Language.HasValue ? domainModel.Metadata.Language.Value.NativeName.Value : null,
|
||||
OriginalLanguageCode = domainModel.Metadata.OriginalLanguage.HasValue ? domainModel.Metadata.OriginalLanguage.Value.LanguageCode : null,
|
||||
OriginalLanguageName = domainModel.Metadata.OriginalLanguage.HasValue ? domainModel.Metadata.OriginalLanguage.Value.LanguageName : null,
|
||||
OriginalLanguageNativeName = domainModel.Metadata.OriginalLanguage.HasValue ? domainModel.Metadata.OriginalLanguage.Value.NativeName.Value : null,
|
||||
Tags = domainModel.Metadata.Tags.ToRepositoryEntities().ToHashSet(),
|
||||
Genres = domainModel.Metadata.Genres.ToRepositoryEntities().ToHashSet(),
|
||||
Publisher = domainModel.Metadata.Publisher.HasValue ? domainModel.Metadata.Publisher.Value : null,
|
||||
PageCount = domainModel.Metadata.PageCount.HasValue ? domainModel.Metadata.PageCount.Value : null,
|
||||
Format = domainModel.Format.ToString(),
|
||||
Edition = domainModel.Edition.HasValue ? domainModel.Edition.Value : null,
|
||||
VolumeNumber = domainModel.VolumeNumber.HasValue ? domainModel.VolumeNumber.Value : null,
|
||||
ASIN = domainModel.ASIN.HasValue ? domainModel.ASIN.Value : null,
|
||||
GoodreadsId = domainModel.GoodreadsId.HasValue ? domainModel.GoodreadsId.Value : null,
|
||||
LCCN = domainModel.LCCN.HasValue ? domainModel.LCCN.Value : null,
|
||||
OCLCNumber = domainModel.OCLCNumber.HasValue ? domainModel.OCLCNumber.Value : null,
|
||||
OpenLibraryId = domainModel.OpenLibraryId.HasValue ? domainModel.OpenLibraryId.Value : null,
|
||||
LibraryThingId = domainModel.LibraryThingId.HasValue ? domainModel.LibraryThingId.Value : null,
|
||||
GoogleBooksId = domainModel.GoogleBooksId.HasValue ? domainModel.GoogleBooksId.Value : null,
|
||||
BarnesAndNobleId = domainModel.BarnesAndNobleId.HasValue ? domainModel.BarnesAndNobleId.Value : null,
|
||||
AppleBooksId = domainModel.AppleBooksId.HasValue ? domainModel.AppleBooksId.Value : null,
|
||||
ISBNs = domainModel.ISBNs.ToRepositoryEntities().ToList(),
|
||||
Ratings = domainModel.Ratings.ToRepositoryEntities().ToList(),
|
||||
Created = domainModel.Created,
|
||||
Updated = domainModel.Updated.HasValue ? domainModel.Updated : null
|
||||
};
|
||||
}
|
||||
}
|
||||
+223
@@ -0,0 +1,223 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Application.Common.Mapping.Common.Metadata;
|
||||
using Lumina.Application.Common.Mapping.WrittenContentLibrary.BookLibrary.Common;
|
||||
using Lumina.Contracts.Entities.Common;
|
||||
using Lumina.Contracts.Entities.WrittenContentLibrary;
|
||||
using Lumina.Contracts.Entities.WrittenContentLibrary.BookLibrary;
|
||||
using Lumina.Contracts.Enums.BookLibrary;
|
||||
using Lumina.Contracts.Responses.WrittenContentLibrary.BookLibrary.Books;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Common.ValueObjects.Metadata;
|
||||
using Lumina.Domain.Core.Aggregates.WrittenContentLibrary.BookLibraryAggregate;
|
||||
using Lumina.Domain.Core.Aggregates.WrittenContentLibrary.BookLibraryAggregate.Entities;
|
||||
using Lumina.Domain.Core.Aggregates.WrittenContentLibrary.BookLibraryAggregate.ValueObjects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.WrittenContentLibrary.BookLibrary.Books;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="BookEntity"/>.
|
||||
/// </summary>
|
||||
public static class BookModelMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="repositoryEntity"/> to <see cref="Book"/>.
|
||||
/// </summary>
|
||||
/// <param name="repositoryEntity">The repository model to be converted.</param>
|
||||
/// <returns>
|
||||
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully converted <see cref="Book"/>, or an error message.
|
||||
/// </returns>
|
||||
public static ErrorOr<Book> ToDomainModel(this BookEntity repositoryEntity)
|
||||
{
|
||||
IEnumerable<ErrorOr<Tag>> tagsResult = repositoryEntity.Tags.ToDomainModels();
|
||||
foreach (ErrorOr<Tag> tagResult in tagsResult)
|
||||
if (tagResult.IsError)
|
||||
return tagResult.Errors;
|
||||
|
||||
IEnumerable<ErrorOr<Genre>> genresResult = repositoryEntity.Genres.ToDomainModels();
|
||||
foreach (ErrorOr<Genre> genreResult in genresResult)
|
||||
if (genreResult.IsError)
|
||||
return genreResult.Errors;
|
||||
|
||||
IEnumerable<ErrorOr<Isbn>> isbnsResult = repositoryEntity.ISBNs.ToDomainModels();
|
||||
foreach (ErrorOr<Isbn> isbnResult in isbnsResult)
|
||||
if (isbnResult.IsError)
|
||||
return isbnResult.Errors;
|
||||
|
||||
IEnumerable<ErrorOr<BookRating>> bookRatingsResult = repositoryEntity.Ratings.ToDomainModels();
|
||||
foreach (ErrorOr<BookRating> bookRatingResult in bookRatingsResult)
|
||||
if (bookRatingResult.IsError)
|
||||
return bookRatingResult.Errors;
|
||||
|
||||
ErrorOr<ReleaseInfo> releaseInfoResult = ReleaseInfo.Create(
|
||||
Optional<DateOnly>.FromNullable(repositoryEntity.OriginalReleaseDate),
|
||||
Optional<int>.FromNullable(repositoryEntity.OriginalReleaseYear),
|
||||
Optional<DateOnly>.FromNullable(repositoryEntity.ReReleaseDate),
|
||||
Optional<int>.FromNullable(repositoryEntity.ReReleaseYear),
|
||||
Optional<string>.FromNullable(repositoryEntity.ReleaseCountry),
|
||||
Optional<string>.FromNullable(repositoryEntity.ReleaseVersion)
|
||||
);
|
||||
if (releaseInfoResult.IsError)
|
||||
return releaseInfoResult.Errors;
|
||||
|
||||
Optional<LanguageInfo> languageInfo = Optional<LanguageInfo>.None();
|
||||
if (repositoryEntity.LanguageCode is not null)
|
||||
{
|
||||
ErrorOr<LanguageInfo> languageInfoResult = LanguageInfo.Create(
|
||||
repositoryEntity.LanguageCode,
|
||||
repositoryEntity.LanguageName,
|
||||
Optional<string>.FromNullable(repositoryEntity.LanguageNativeName)
|
||||
);
|
||||
if (languageInfoResult.IsError)
|
||||
return languageInfoResult.Errors;
|
||||
languageInfo = languageInfoResult.Value;
|
||||
}
|
||||
|
||||
Optional<LanguageInfo> originalLanguageCode = Optional<LanguageInfo>.None();
|
||||
if (repositoryEntity.OriginalLanguageCode is not null)
|
||||
{
|
||||
ErrorOr<LanguageInfo> originalLanguageInfoResult = LanguageInfo.Create(
|
||||
repositoryEntity.OriginalLanguageCode,
|
||||
repositoryEntity.OriginalLanguageName!,
|
||||
Optional<string>.FromNullable(repositoryEntity.OriginalLanguageNativeName)
|
||||
);
|
||||
if (originalLanguageInfoResult.IsError)
|
||||
return originalLanguageInfoResult.Errors;
|
||||
originalLanguageCode = originalLanguageInfoResult.Value;
|
||||
}
|
||||
|
||||
ErrorOr<WrittenContentMetadata> writtenContentMetadataResult = WrittenContentMetadata.Create(
|
||||
repositoryEntity.Title,
|
||||
Optional<string>.FromNullable(repositoryEntity.OriginalTitle),
|
||||
Optional<string>.FromNullable(repositoryEntity.Description),
|
||||
releaseInfoResult.Value,
|
||||
genresResult.Select(genre => genre.Value).ToList(),
|
||||
tagsResult.Select(tag => tag.Value).ToList(),
|
||||
languageInfo,
|
||||
originalLanguageCode,
|
||||
Optional<string>.FromNullable(repositoryEntity.Publisher),
|
||||
Optional<int>.FromNullable(repositoryEntity.PageCount)
|
||||
);
|
||||
if (writtenContentMetadataResult.IsError)
|
||||
return writtenContentMetadataResult.Errors;
|
||||
|
||||
Optional<BookFormat> bookFormat = Optional<BookFormat>.FromNullable(!string.IsNullOrWhiteSpace(repositoryEntity.Format) ? Enum.Parse<BookFormat>(repositoryEntity.Format) : (BookFormat?)null);
|
||||
|
||||
return Book.Create(
|
||||
BookId.Create(repositoryEntity.Id),
|
||||
writtenContentMetadataResult.Value,
|
||||
bookFormat,
|
||||
Optional<string>.FromNullable(repositoryEntity.Edition),
|
||||
Optional<int>.FromNullable(repositoryEntity.VolumeNumber),
|
||||
Optional<BookSeries>.None(),
|
||||
Optional<string>.FromNullable(repositoryEntity.ASIN),
|
||||
Optional<string>.FromNullable(repositoryEntity.GoodreadsId),
|
||||
Optional<string>.FromNullable(repositoryEntity.LCCN),
|
||||
Optional<string>.FromNullable(repositoryEntity.OCLCNumber),
|
||||
Optional<string>.FromNullable(repositoryEntity.OpenLibraryId),
|
||||
Optional<string>.FromNullable(repositoryEntity.LibraryThingId),
|
||||
Optional<string>.FromNullable(repositoryEntity.GoogleBooksId),
|
||||
Optional<string>.FromNullable(repositoryEntity.BarnesAndNobleId),
|
||||
Optional<string>.FromNullable(repositoryEntity.AppleBooksId),
|
||||
repositoryEntity.Created,
|
||||
Optional<DateTime>.FromNullable(repositoryEntity.Updated),
|
||||
isbnsResult.Select(isbn => isbn.Value).ToList(),
|
||||
[],
|
||||
bookRatingsResult.Select(bookRating => bookRating.Value).ToList());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts <paramref name="repositoryEntities"/> to a collection of <see cref="Book"/>.
|
||||
/// </summary>
|
||||
/// <param name="repositoryEntities">The repository models to be converted.</param>
|
||||
/// <returns>The converted domain models.</returns>
|
||||
/// <returns>
|
||||
/// An colection of <see cref="ErrorOr{TValue}"/> containing either successfully converted <see cref="Book"/>, or error messages.
|
||||
/// </returns>
|
||||
public static IEnumerable<ErrorOr<Book>> ToDomainModels(this IEnumerable<BookEntity> repositoryEntities)
|
||||
{
|
||||
return repositoryEntities.Select(repositoryEntity => repositoryEntity.ToDomainModel());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts <paramref name="repositoryEntity"/> to <see cref="BookResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="repositoryEntity">The repository model to be converted.</param>
|
||||
/// <returns>The converted response model.</returns>
|
||||
public static BookResponse ToResponse(this BookEntity repositoryEntity)
|
||||
{
|
||||
ReleaseInfoEntity releaseInfoModel = new(
|
||||
repositoryEntity.OriginalReleaseDate,
|
||||
repositoryEntity.OriginalReleaseYear,
|
||||
repositoryEntity.ReReleaseDate,
|
||||
repositoryEntity.ReReleaseYear,
|
||||
repositoryEntity.ReleaseCountry,
|
||||
repositoryEntity.ReleaseVersion
|
||||
);
|
||||
// language and original language make sense only if their subproperties have values
|
||||
LanguageInfoEntity? languageInfoModel = (!string.IsNullOrWhiteSpace(repositoryEntity.LanguageCode) ||
|
||||
!string.IsNullOrWhiteSpace(repositoryEntity.LanguageName) ||
|
||||
!string.IsNullOrWhiteSpace(repositoryEntity.LanguageNativeName))
|
||||
? new LanguageInfoEntity(
|
||||
repositoryEntity.LanguageCode,
|
||||
repositoryEntity.LanguageName,
|
||||
repositoryEntity.LanguageNativeName
|
||||
) : null;
|
||||
LanguageInfoEntity? originalLanguageInfoModel = (!string.IsNullOrWhiteSpace(repositoryEntity.OriginalLanguageCode) ||
|
||||
!string.IsNullOrWhiteSpace(repositoryEntity.OriginalLanguageName) ||
|
||||
!string.IsNullOrWhiteSpace(repositoryEntity.OriginalLanguageNativeName))
|
||||
? new LanguageInfoEntity(
|
||||
repositoryEntity.OriginalLanguageCode,
|
||||
repositoryEntity.OriginalLanguageName,
|
||||
repositoryEntity.OriginalLanguageNativeName
|
||||
) : null;
|
||||
WrittenContentMetadataEntity metadata = new(
|
||||
repositoryEntity.Title,
|
||||
repositoryEntity.OriginalTitle,
|
||||
repositoryEntity.Description,
|
||||
releaseInfoModel,
|
||||
[.. repositoryEntity.Genres],
|
||||
[.. repositoryEntity.Tags],
|
||||
languageInfoModel,
|
||||
originalLanguageInfoModel,
|
||||
repositoryEntity.Publisher,
|
||||
repositoryEntity.PageCount
|
||||
);
|
||||
return new BookResponse(
|
||||
repositoryEntity.Id,
|
||||
metadata,
|
||||
!string.IsNullOrWhiteSpace(repositoryEntity.Format) ? Enum.Parse<BookFormat>(repositoryEntity.Format) : null,
|
||||
repositoryEntity.Edition,
|
||||
repositoryEntity.VolumeNumber,
|
||||
null,
|
||||
repositoryEntity.ASIN,
|
||||
repositoryEntity.GoodreadsId,
|
||||
repositoryEntity.LCCN,
|
||||
repositoryEntity.OCLCNumber,
|
||||
repositoryEntity.OpenLibraryId,
|
||||
repositoryEntity.LibraryThingId,
|
||||
repositoryEntity.GoogleBooksId,
|
||||
repositoryEntity.BarnesAndNobleId,
|
||||
repositoryEntity.AppleBooksId,
|
||||
repositoryEntity.ISBNs,
|
||||
null,
|
||||
repositoryEntity.Ratings,
|
||||
repositoryEntity.Created,
|
||||
repositoryEntity.Updated
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts <paramref name="repositoryEntities"/> to a collection of <see cref="Book"/>.
|
||||
/// </summary>
|
||||
/// <param name="repositoryEntities">The repository models to be converted.</param>
|
||||
/// <returns>The converted reponses.</returns>
|
||||
public static IEnumerable<BookResponse> ToResponses(this IEnumerable<BookEntity> repositoryEntities)
|
||||
{
|
||||
return repositoryEntities.Select(repositoryEntity => repositoryEntity.ToResponse());
|
||||
}
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.Entities.WrittenContentLibrary.BookLibrary;
|
||||
using Lumina.Domain.Core.Aggregates.WrittenContentLibrary.BookLibraryAggregate.ValueObjects;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.WrittenContentLibrary.BookLibrary.Common;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="BookRating"/>.
|
||||
/// </summary>
|
||||
public static class BookRatingMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="domainModel"/> to <see cref="BookRatingEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="domainModel">The domain model to be converted.</param>
|
||||
/// <returns>The converted repository entity.</returns>
|
||||
public static BookRatingEntity ToRepositoryEntity(this BookRating domainModel)
|
||||
{
|
||||
return new BookRatingEntity(
|
||||
domainModel.Value,
|
||||
domainModel.MaxValue,
|
||||
domainModel.Source.HasValue ? domainModel.Source.Value : null,
|
||||
domainModel.VoteCount.HasValue ? domainModel.VoteCount.Value : null
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts <paramref name="domainModels"/> to a collection of <see cref="BookRatingEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="domainModels">The domain models to be converted.</param>
|
||||
/// <returns>The converted repository entities.</returns>
|
||||
public static IEnumerable<BookRatingEntity> ToRepositoryEntities(this IEnumerable<BookRating> domainModels)
|
||||
{
|
||||
return domainModels.Select(domainModel => domainModel.ToRepositoryEntity());
|
||||
}
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Contracts.Entities.WrittenContentLibrary.BookLibrary;
|
||||
using Lumina.Contracts.Enums.BookLibrary;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.Aggregates.WrittenContentLibrary.BookLibraryAggregate.ValueObjects;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.WrittenContentLibrary.BookLibrary.Common;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="BookRatingEntity"/>.
|
||||
/// </summary>
|
||||
public static class BookRatingModelMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="repositoryEntity"/> to <see cref="BookRating"/>.
|
||||
/// </summary>
|
||||
/// <param name="repositoryEntity">The repository model to be converted.</param>
|
||||
/// <returns>The converted domain model.</returns>
|
||||
public static ErrorOr<BookRating> ToDomainModel(this BookRatingEntity repositoryEntity)
|
||||
{
|
||||
return BookRating.Create(
|
||||
repositoryEntity.Value ?? default,
|
||||
repositoryEntity.MaxValue ?? default,
|
||||
Optional<BookRatingSource>.FromNullable(repositoryEntity.Source),
|
||||
Optional<int>.FromNullable(repositoryEntity.VoteCount)
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts <paramref name="repositoryEntities"/> to a collection of <see cref="BookRating"/>.
|
||||
/// </summary>
|
||||
/// <param name="repositoryEntities">The repository models to be converted.</param>
|
||||
/// <returns>The converted domain models.</returns>
|
||||
public static IEnumerable<ErrorOr<BookRating>> ToDomainModels(this IEnumerable<BookRatingEntity> repositoryEntities)
|
||||
{
|
||||
return repositoryEntities.Select(domainModel => domainModel.ToDomainModel());
|
||||
}
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.Entities.WrittenContentLibrary.BookLibrary;
|
||||
using Lumina.Domain.Core.Aggregates.WrittenContentLibrary.BookLibraryAggregate.ValueObjects;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.WrittenContentLibrary.BookLibrary.Common;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="Isbn"/>.
|
||||
/// </summary>
|
||||
public static class IsbnMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="domainModel"/> to <see cref="IsbnEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="domainModel">The domain model to be converted.</param>
|
||||
/// <returns>The converted repository entity.</returns>
|
||||
public static IsbnEntity ToRepositoryEntity(this Isbn domainModel)
|
||||
{
|
||||
return new IsbnEntity(
|
||||
domainModel.Value,
|
||||
domainModel.Format
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts <paramref name="domainModels"/> to a collection of <see cref="IsbnEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="domainModels">The domain models to be converted.</param>
|
||||
/// <returns>The converted repository entities.</returns>
|
||||
public static IEnumerable<IsbnEntity> ToRepositoryEntities(this IEnumerable<Isbn> domainModels)
|
||||
{
|
||||
return domainModels.Select(domainModel => domainModel.ToRepositoryEntity());
|
||||
}
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Contracts.Entities.WrittenContentLibrary.BookLibrary;
|
||||
using Lumina.Contracts.Enums.BookLibrary;
|
||||
using Lumina.Domain.Core.Aggregates.WrittenContentLibrary.BookLibraryAggregate.ValueObjects;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.WrittenContentLibrary.BookLibrary.Common;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="IsbnEntity"/>.
|
||||
/// </summary>
|
||||
public static class IsbnModelMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="repositoryEntity"/> to <see cref="Isbn"/>.
|
||||
/// </summary>
|
||||
/// <param name="repositoryEntity">The repository model to be converted.</param>
|
||||
/// <returns>
|
||||
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully converted <see cref="Isbn"/>, or an error message.
|
||||
/// </returns>
|
||||
public static ErrorOr<Isbn> ToDomainModel(this IsbnEntity repositoryEntity)
|
||||
{
|
||||
return Isbn.Create(
|
||||
repositoryEntity.Value,
|
||||
repositoryEntity.Format ?? IsbnFormat.Isbn13
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts <paramref name="repositoryEntities"/> to a collection of <see cref="Isbn"/>.
|
||||
/// </summary>
|
||||
/// <param name="repositoryEntities">The repository models to be converted.</param>
|
||||
/// <returns>The converted domain models.</returns>
|
||||
public static IEnumerable<ErrorOr<Isbn>> ToDomainModels(this IEnumerable<IsbnEntity> repositoryEntities)
|
||||
{
|
||||
return repositoryEntities.Select(domainModel => domainModel.ToDomainModel());
|
||||
}
|
||||
}
|
||||
-15
@@ -1,15 +0,0 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Contracts.Responses.FileManagement;
|
||||
using Mediator;
|
||||
using System.Collections.Generic;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Core.FileManagement.Directories.Queries.GetDirectories;
|
||||
|
||||
/// <summary>
|
||||
/// Query for retrieving the list of directories at a path.
|
||||
/// </summary>
|
||||
/// <param name="Path">The path for which to retrieve the list of directories.</param>
|
||||
/// <param name="IncludeHiddenElements">Whether to include hidden directories or not.</param>
|
||||
public record GetDirectoriesQuery(string Path, bool IncludeHiddenElements) : IRequest<ErrorOr<IEnumerable<DirectoryResponse>>>;
|
||||
-15
@@ -1,15 +0,0 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Contracts.Responses.FileManagement;
|
||||
using Mediator;
|
||||
using System.Collections.Generic;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Core.FileManagement.Directories.Queries.GetTreeDirectories;
|
||||
|
||||
/// <summary>
|
||||
/// Query for retrieving the list of directories at a path.
|
||||
/// </summary>
|
||||
/// <param name="Path">The path for which to retrieve the list of directories.</param>
|
||||
/// <param name="IncludeHiddenElements">Whether to include hidden directories or not.</param>
|
||||
public record GetTreeDirectoriesQuery(string Path, bool IncludeHiddenElements) : IRequest<ErrorOr<IEnumerable<FileSystemTreeNodeResponse>>>;
|
||||
@@ -1,15 +0,0 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Contracts.Responses.FileManagement;
|
||||
using Mediator;
|
||||
using System.Collections.Generic;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Core.FileManagement.Files.Queries.GetFiles;
|
||||
|
||||
/// <summary>
|
||||
/// Query for retrieving the list of files at a path.
|
||||
/// </summary>
|
||||
/// <param name="Path">The path for which to retrieve the list of files.</param>
|
||||
/// <param name="IncludeHiddenElements">Whether to include hidden files and directories or not.</param>
|
||||
public record GetFilesQuery(string Path, bool IncludeHiddenElements) : IRequest<ErrorOr<IEnumerable<FileResponse>>>;
|
||||
-15
@@ -1,15 +0,0 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Contracts.Responses.FileManagement;
|
||||
using Mediator;
|
||||
using System.Collections.Generic;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Core.FileManagement.Files.Queries.GetTreeFiles;
|
||||
|
||||
/// <summary>
|
||||
/// Query for retrieving the list of files at a path.
|
||||
/// </summary>
|
||||
/// <param name="Path">The path for which to retrieve the list of files.</param>
|
||||
/// <param name="IncludeHiddenElements">Whether to include hidden files and directories or not.</param>
|
||||
public record GetTreeFilesQuery(string Path, bool IncludeHiddenElements) : IRequest<ErrorOr<IEnumerable<FileSystemTreeNodeResponse>>>;
|
||||
-16
@@ -1,16 +0,0 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Contracts.Responses.FileManagement;
|
||||
using Mediator;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Core.FileManagement.Paths.Commands.CombinePath;
|
||||
|
||||
/// <summary>
|
||||
/// Command for combining two file system path.
|
||||
/// </summary>
|
||||
/// <param name="OriginalPath">The path to combine to.</param>
|
||||
/// <param name="NewPath">The path to combine with.</param>
|
||||
public record CombinePathCommand(
|
||||
string OriginalPath, string NewPath
|
||||
) : IRequest<ErrorOr<PathSegmentResponse>>;
|
||||
-16
@@ -1,16 +0,0 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Contracts.Responses.FileManagement;
|
||||
using Mediator;
|
||||
using System.Collections.Generic;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Core.FileManagement.Paths.Commands.SplitPath;
|
||||
|
||||
/// <summary>
|
||||
/// Command for splitting a file system path.
|
||||
/// </summary>
|
||||
/// <param name="Path">The path to split.</param>
|
||||
public record SplitPathCommand(
|
||||
string Path
|
||||
) : IRequest<ErrorOr<IEnumerable<PathSegmentResponse>>>;
|
||||
-13
@@ -1,13 +0,0 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.Responses.FileManagement;
|
||||
using Mediator;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Core.FileManagement.Paths.Queries.CheckPathExists;
|
||||
|
||||
/// <summary>
|
||||
/// Query for retrieving the existence of a file system path.
|
||||
/// </summary>
|
||||
/// <param name="Path">The path for which to check the existence.</param>
|
||||
/// <param name="IncludeHiddenElements">Whether to include hidden file system elements or not.</param>
|
||||
public record CheckPathExistsQuery(string Path, bool IncludeHiddenElements) : IRequest<PathExistsResponse>;
|
||||
-14
@@ -1,14 +0,0 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Contracts.Responses.FileManagement;
|
||||
using Mediator;
|
||||
using System.Collections.Generic;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Core.FileManagement.Paths.Queries.GetPathParent;
|
||||
|
||||
/// <summary>
|
||||
/// Query for retrieving the parent of a file system path.
|
||||
/// </summary>
|
||||
/// <param name="Path">The path for which to get the parent.</param>
|
||||
public record GetPathParentQuery(string Path) : IRequest<ErrorOr<IEnumerable<PathSegmentResponse>>>;
|
||||
-13
@@ -1,13 +0,0 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Contracts.Responses.FileManagement;
|
||||
using Mediator;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Core.FileManagement.Paths.Queries.GetPathRoot;
|
||||
|
||||
/// <summary>
|
||||
/// Query for retrieving the root of a path.
|
||||
/// </summary>
|
||||
/// <param name="Path">The path for which to get the path root.</param>
|
||||
public record GetPathRootQuery(string Path) : IRequest<ErrorOr<PathSegmentResponse>>;
|
||||
-12
@@ -1,12 +0,0 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.Responses.FileManagement;
|
||||
using Mediator;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Core.FileManagement.Paths.Queries.ValidatePath;
|
||||
|
||||
/// <summary>
|
||||
/// Query for validating a path.
|
||||
/// </summary>
|
||||
/// <param name="Path">The path to be validated.</param>
|
||||
public record ValidatePathQuery(string Path) : IRequest<PathValidResponse>;
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Contracts.Responses.FileSystemManagement.Directories;
|
||||
using Mediator;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Core.FileSystemManagement.Directories.Queries.GetDirectories;
|
||||
|
||||
/// <summary>
|
||||
/// Query for retrieving the list of directories at a path.
|
||||
/// </summary>
|
||||
/// <param name="Path">The path for which to retrieve the list of directories.</param>
|
||||
/// <param name="IncludeHiddenElements">Whether to include hidden directories or not.</param>
|
||||
[DebuggerDisplay("Path: {Path}")]
|
||||
public record GetDirectoriesQuery(
|
||||
string? Path,
|
||||
bool IncludeHiddenElements
|
||||
) : IRequest<ErrorOr<IEnumerable<DirectoryResponse>>>;
|
||||
+8
-12
@@ -1,17 +1,16 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Contracts.Responses.FileManagement;
|
||||
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Entities;
|
||||
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Services;
|
||||
using Mapster;
|
||||
using MapsterMapper;
|
||||
using Lumina.Application.Common.Mapping.FileSystemManagement.Directories;
|
||||
using Lumina.Contracts.Responses.FileSystemManagement.Directories;
|
||||
using Lumina.Domain.Core.Aggregates.FileSystemManagement.FileSystemManagementAggregate.Entities;
|
||||
using Lumina.Domain.Core.Aggregates.FileSystemManagement.FileSystemManagementAggregate.Services;
|
||||
using Mediator;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Core.FileManagement.Directories.Queries.GetDirectories;
|
||||
namespace Lumina.Application.Core.FileSystemManagement.Directories.Queries.GetDirectories;
|
||||
|
||||
/// <summary>
|
||||
/// Handler for the query to get all directories.
|
||||
@@ -19,17 +18,14 @@ namespace Lumina.Application.Core.FileManagement.Directories.Queries.GetDirector
|
||||
public class GetDirectoriesQueryHandler : IRequestHandler<GetDirectoriesQuery, ErrorOr<IEnumerable<DirectoryResponse>>>
|
||||
{
|
||||
private readonly IDirectoryService _directoryService;
|
||||
private readonly IMapper _mapper;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetDirectoriesQueryHandler"/> class.
|
||||
/// </summary>
|
||||
/// <param name="directoryService">Injected service for handling directories.</param>
|
||||
/// <param name="mapper">Injected service for mapping objects.</param>
|
||||
public GetDirectoriesQueryHandler(IDirectoryService directoryService, IMapper mapper)
|
||||
public GetDirectoriesQueryHandler(IDirectoryService directoryService)
|
||||
{
|
||||
_directoryService = directoryService;
|
||||
_mapper = mapper;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -42,7 +38,7 @@ public class GetDirectoriesQueryHandler : IRequestHandler<GetDirectoriesQuery, E
|
||||
/// </returns>
|
||||
public ValueTask<ErrorOr<IEnumerable<DirectoryResponse>>> Handle(GetDirectoriesQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
ErrorOr<IEnumerable<Directory>> result = _directoryService.GetSubdirectories(request.Path, request.IncludeHiddenElements);
|
||||
return ValueTask.FromResult(result.Match(values => ErrorOrFactory.From(_mapper.Map<IEnumerable<DirectoryResponse>>(values)), errors => errors));
|
||||
ErrorOr<IEnumerable<Directory>> result = _directoryService.GetSubdirectories(request.Path!, request.IncludeHiddenElements);
|
||||
return ValueTask.FromResult(result.Match(values => ErrorOrFactory.From(values.ToResponses()), errors => errors));
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -3,7 +3,7 @@ using FluentValidation;
|
||||
using Lumina.Domain.Common.Errors;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Core.FileManagement.Directories.Queries.GetDirectories;
|
||||
namespace Lumina.Application.Core.FileSystemManagement.Directories.Queries.GetDirectories;
|
||||
|
||||
/// <summary>
|
||||
/// Validates the needed validation rules for <see cref="GetDirectoriesQuery"/>.
|
||||
@@ -15,6 +15,6 @@ public class GetDirectoriesQueryValidator : AbstractValidator<GetDirectoriesQuer
|
||||
/// </summary>
|
||||
public GetDirectoriesQueryValidator()
|
||||
{
|
||||
RuleFor(x => x.Path).NotEmpty().WithMessage(Errors.FileManagement.PathCannotBeEmpty.Code);
|
||||
RuleFor(x => x.Path).NotEmpty().WithMessage(Errors.FileSystemManagement.PathCannotBeEmpty.Description);
|
||||
}
|
||||
}
|
||||
+9
-3
@@ -1,11 +1,12 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Contracts.Responses.FileManagement;
|
||||
using Lumina.Contracts.Responses.FileSystemManagement.Common;
|
||||
using Mediator;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Core.FileManagement.Directories.Queries.GetDirectoryTree;
|
||||
namespace Lumina.Application.Core.FileSystemManagement.Directories.Queries.GetDirectoryTree;
|
||||
|
||||
/// <summary>
|
||||
/// Query for retrieving the tree of directories of a path.
|
||||
@@ -13,4 +14,9 @@ namespace Lumina.Application.Core.FileManagement.Directories.Queries.GetDirector
|
||||
/// <param name="Path">The path for which to retrieve the tree of directories.</param>
|
||||
/// <param name="IncludeFiles">Whether to include files in the directory tree or not.</param>
|
||||
/// <param name="IncludeHiddenElements">Whether to include hidden files and directories or not.</param>
|
||||
public record GetDirectoryTreeQuery(string Path, bool IncludeFiles, bool IncludeHiddenElements) : IRequest<ErrorOr<IEnumerable<FileSystemTreeNodeResponse>>>;
|
||||
[DebuggerDisplay("Path: {Path}")]
|
||||
public record GetDirectoryTreeQuery(
|
||||
string? Path,
|
||||
bool IncludeFiles,
|
||||
bool IncludeHiddenElements
|
||||
) : IRequest<ErrorOr<IEnumerable<FileSystemTreeNodeResponse>>>;
|
||||
+9
-9
@@ -1,12 +1,12 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Application.Common.Mapping.FileSystemManagement.FileSystem;
|
||||
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 Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Services;
|
||||
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.ValueObjects;
|
||||
using Mapster;
|
||||
using Lumina.Contracts.Responses.FileSystemManagement.Common;
|
||||
using Lumina.Domain.Core.Aggregates.FileSystemManagement.FileSystemManagementAggregate;
|
||||
using Lumina.Domain.Core.Aggregates.FileSystemManagement.FileSystemManagementAggregate.Entities;
|
||||
using Lumina.Domain.Core.Aggregates.FileSystemManagement.FileSystemManagementAggregate.Services;
|
||||
using Lumina.Domain.Core.Aggregates.FileSystemManagement.FileSystemManagementAggregate.ValueObjects;
|
||||
using Mediator;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -14,7 +14,7 @@ using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Core.FileManagement.Directories.Queries.GetDirectoryTree;
|
||||
namespace Lumina.Application.Core.FileSystemManagement.Directories.Queries.GetDirectoryTree;
|
||||
|
||||
/// <summary>
|
||||
/// Handler for the query to get a directory tree.
|
||||
@@ -56,7 +56,7 @@ public class GetDirectoryTreeQueryHandler : IRequestHandler<GetDirectoryTreeQuer
|
||||
return getDrivesResult.Errors;
|
||||
result.AddRange(getDrivesResult.Value);
|
||||
|
||||
ErrorOr<IEnumerable<PathSegment>> pathPartsResults = _pathService.ParsePath(request.Path);
|
||||
ErrorOr<IEnumerable<PathSegment>> pathPartsResults = _pathService.ParsePath(request.Path!);
|
||||
if (pathPartsResults.IsError)
|
||||
return pathPartsResults.Errors;
|
||||
|
||||
@@ -84,7 +84,7 @@ public class GetDirectoryTreeQueryHandler : IRequestHandler<GetDirectoryTreeQuer
|
||||
ErrorOr<IEnumerable<FileSystemItem>> driveResult = _driveService.GetDrives();
|
||||
if (driveResult.IsError)
|
||||
return driveResult.Errors;
|
||||
return ErrorOrFactory.From(driveResult.Value.Adapt<IEnumerable<FileSystemTreeNodeResponse>>());
|
||||
return ErrorOrFactory.From(driveResult.Value.ToTreeNodeResponses());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
+2
-2
@@ -3,7 +3,7 @@ using FluentValidation;
|
||||
using Lumina.Domain.Common.Errors;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Core.FileManagement.Directories.Queries.GetDirectoryTree;
|
||||
namespace Lumina.Application.Core.FileSystemManagement.Directories.Queries.GetDirectoryTree;
|
||||
|
||||
/// <summary>
|
||||
/// Validates the needed validation rules for <see cref="GetDirectoryTreeQuery"/>.
|
||||
@@ -15,6 +15,6 @@ public class GetDirectoryTreeQueryValidator : AbstractValidator<GetDirectoryTree
|
||||
/// </summary>
|
||||
public GetDirectoryTreeQueryValidator()
|
||||
{
|
||||
RuleFor(x => x.Path).NotEmpty().WithMessage(Errors.FileManagement.PathCannotBeEmpty.Code);
|
||||
RuleFor(x => x.Path).NotEmpty().WithMessage(Errors.FileSystemManagement.PathCannotBeEmpty.Description);
|
||||
}
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Contracts.Responses.FileSystemManagement.Common;
|
||||
using Mediator;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Core.FileSystemManagement.Directories.Queries.GetTreeDirectories;
|
||||
|
||||
/// <summary>
|
||||
/// Query for retrieving the list of directories at a path.
|
||||
/// </summary>
|
||||
/// <param name="Path">The path for which to retrieve the list of directories.</param>
|
||||
/// <param name="IncludeHiddenElements">Whether to include hidden directories or not.</param>
|
||||
[DebuggerDisplay("Path: {Path}")]
|
||||
public record GetTreeDirectoriesQuery(
|
||||
string? Path,
|
||||
bool IncludeHiddenElements
|
||||
) : IRequest<ErrorOr<IEnumerable<FileSystemTreeNodeResponse>>>;
|
||||
+8
-12
@@ -1,17 +1,16 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Contracts.Responses.FileManagement;
|
||||
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Entities;
|
||||
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Services;
|
||||
using Mapster;
|
||||
using MapsterMapper;
|
||||
using Lumina.Application.Common.Mapping.FileSystemManagement.Directories;
|
||||
using Lumina.Contracts.Responses.FileSystemManagement.Common;
|
||||
using Lumina.Domain.Core.Aggregates.FileSystemManagement.FileSystemManagementAggregate.Entities;
|
||||
using Lumina.Domain.Core.Aggregates.FileSystemManagement.FileSystemManagementAggregate.Services;
|
||||
using Mediator;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Core.FileManagement.Directories.Queries.GetTreeDirectories;
|
||||
namespace Lumina.Application.Core.FileSystemManagement.Directories.Queries.GetTreeDirectories;
|
||||
|
||||
/// <summary>
|
||||
/// Handler for the query to get all directories.
|
||||
@@ -19,17 +18,14 @@ namespace Lumina.Application.Core.FileManagement.Directories.Queries.GetTreeDire
|
||||
public class GetTreeDirectoriesQueryHandler : IRequestHandler<GetTreeDirectoriesQuery, ErrorOr<IEnumerable<FileSystemTreeNodeResponse>>>
|
||||
{
|
||||
private readonly IDirectoryService _directoryService;
|
||||
private readonly IMapper _mapper;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetTreeDirectoriesQueryHandler"/> class.
|
||||
/// </summary>
|
||||
/// <param name="directoryService">Injected service for handling directories.</param>
|
||||
/// <param name="mapper">Injected service for mapping objects.</param>
|
||||
public GetTreeDirectoriesQueryHandler(IDirectoryService directoryService, IMapper mapper)
|
||||
public GetTreeDirectoriesQueryHandler(IDirectoryService directoryService)
|
||||
{
|
||||
_directoryService = directoryService;
|
||||
_mapper = mapper;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -42,7 +38,7 @@ public class GetTreeDirectoriesQueryHandler : IRequestHandler<GetTreeDirectories
|
||||
/// </returns>
|
||||
public ValueTask<ErrorOr<IEnumerable<FileSystemTreeNodeResponse>>> Handle(GetTreeDirectoriesQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
ErrorOr<IEnumerable<Directory>> result = _directoryService.GetSubdirectories(request.Path, request.IncludeHiddenElements);
|
||||
return ValueTask.FromResult(result.Match(values => ErrorOrFactory.From(_mapper.Map<IEnumerable<FileSystemTreeNodeResponse>>(values)), errors => errors));
|
||||
ErrorOr<IEnumerable<Directory>> result = _directoryService.GetSubdirectories(request.Path!, request.IncludeHiddenElements);
|
||||
return ValueTask.FromResult(result.Match(values => ErrorOrFactory.From(values.ToFileSystemTreeNodeResponses()), errors => errors));
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -3,7 +3,7 @@ using FluentValidation;
|
||||
using Lumina.Domain.Common.Errors;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Core.FileManagement.Directories.Queries.GetTreeDirectories;
|
||||
namespace Lumina.Application.Core.FileSystemManagement.Directories.Queries.GetTreeDirectories;
|
||||
|
||||
/// <summary>
|
||||
/// Validates the needed validation rules for <see cref="GetTreeDirectoriesQuery"/>.
|
||||
@@ -15,6 +15,6 @@ public class GetTreeDirectoriesQueryValidator : AbstractValidator<GetTreeDirecto
|
||||
/// </summary>
|
||||
public GetTreeDirectoriesQueryValidator()
|
||||
{
|
||||
RuleFor(x => x.Path).NotEmpty().WithMessage(Errors.FileManagement.PathCannotBeEmpty.Code);
|
||||
RuleFor(x => x.Path).NotEmpty().WithMessage(Errors.FileSystemManagement.PathCannotBeEmpty.Description);
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,11 +1,11 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Contracts.Responses.FileManagement;
|
||||
using Lumina.Contracts.Responses.FileSystemManagement.Common;
|
||||
using Mediator;
|
||||
using System.Collections.Generic;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Core.FileManagement.Drives.Queries.GetDrives;
|
||||
namespace Lumina.Application.Core.FileSystemManagement.Drives.Queries.GetDrives;
|
||||
|
||||
/// <summary>
|
||||
/// Query for retrieving the list of drives.
|
||||
+7
-11
@@ -1,17 +1,16 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Contracts.Responses.FileManagement;
|
||||
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate;
|
||||
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Services;
|
||||
using Mapster;
|
||||
using MapsterMapper;
|
||||
using Lumina.Application.Common.Mapping.FileSystemManagement.FileSystem;
|
||||
using Lumina.Contracts.Responses.FileSystemManagement.Common;
|
||||
using Lumina.Domain.Core.Aggregates.FileSystemManagement.FileSystemManagementAggregate;
|
||||
using Lumina.Domain.Core.Aggregates.FileSystemManagement.FileSystemManagementAggregate.Services;
|
||||
using Mediator;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Core.FileManagement.Drives.Queries.GetDrives;
|
||||
namespace Lumina.Application.Core.FileSystemManagement.Drives.Queries.GetDrives;
|
||||
|
||||
/// <summary>
|
||||
/// Handler for the query to get all drives.
|
||||
@@ -19,17 +18,14 @@ namespace Lumina.Application.Core.FileManagement.Drives.Queries.GetDrives;
|
||||
public class GetDrivesQueryHandler : IRequestHandler<GetDrivesQuery, ErrorOr<IEnumerable<FileSystemTreeNodeResponse>>>
|
||||
{
|
||||
private readonly IDriveService _driveService;
|
||||
private readonly IMapper _mapper;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetDrivesQueryHandler"/> class.
|
||||
/// </summary>
|
||||
/// <param name="driveService">Injected service for handling file system drives.</param>
|
||||
/// <param name="mapper">Injected service for mapping objects.</param>
|
||||
public GetDrivesQueryHandler(IDriveService driveService, IMapper mapper)
|
||||
public GetDrivesQueryHandler(IDriveService driveService)
|
||||
{
|
||||
_driveService = driveService;
|
||||
_mapper = mapper;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -43,6 +39,6 @@ public class GetDrivesQueryHandler : IRequestHandler<GetDrivesQuery, ErrorOr<IEn
|
||||
public ValueTask<ErrorOr<IEnumerable<FileSystemTreeNodeResponse>>> Handle(GetDrivesQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
ErrorOr<IEnumerable<FileSystemItem>> result = _driveService.GetDrives();
|
||||
return ValueTask.FromResult(result.Match(values => ErrorOrFactory.From(_mapper.Map<IEnumerable<FileSystemTreeNodeResponse>>(values)), errors => errors));
|
||||
return ValueTask.FromResult(result.Match(values => ErrorOrFactory.From(values.ToTreeNodeResponses()), errors => errors));
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,9 +1,9 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.Responses.FileManagement;
|
||||
using Lumina.Contracts.Responses.FileSystemManagement.FileSystem;
|
||||
using Mediator;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Core.FileManagement.FileSystem.Queries.GetFileSystem;
|
||||
namespace Lumina.Application.Core.FileSystemManagement.FileSystem.Queries.GetFileSystem;
|
||||
|
||||
/// <summary>
|
||||
/// Query for retrieving the file system type.
|
||||
+3
-3
@@ -1,12 +1,12 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.Responses.FileManagement;
|
||||
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Strategies.Platform;
|
||||
using Lumina.Contracts.Responses.FileSystemManagement.FileSystem;
|
||||
using Lumina.Domain.Core.Aggregates.FileSystemManagement.FileSystemManagementAggregate.Strategies.Platform;
|
||||
using Mediator;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Core.FileManagement.FileSystem.Queries.GetFileSystem;
|
||||
namespace Lumina.Application.Core.FileSystemManagement.FileSystem.Queries.GetFileSystem;
|
||||
|
||||
/// <summary>
|
||||
/// Handler for the query to get the file system type.
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Contracts.Responses.FileSystemManagement.Files;
|
||||
using Mediator;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Core.FileSystemManagement.Files.Queries.GetFiles;
|
||||
|
||||
/// <summary>
|
||||
/// Query for retrieving the list of files at a path.
|
||||
/// </summary>
|
||||
/// <param name="Path">The path for which to retrieve the list of files.</param>
|
||||
/// <param name="IncludeHiddenElements">Whether to include hidden files and directories or not.</param>
|
||||
[DebuggerDisplay("Path: {Path}")]
|
||||
public record GetFilesQuery(
|
||||
string? Path,
|
||||
bool IncludeHiddenElements
|
||||
) : IRequest<ErrorOr<IEnumerable<FileResponse>>>;
|
||||
+8
-12
@@ -1,17 +1,16 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Contracts.Responses.FileManagement;
|
||||
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Entities;
|
||||
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Services;
|
||||
using Mapster;
|
||||
using MapsterMapper;
|
||||
using Lumina.Application.Common.Mapping.FileSystemManagement.Files;
|
||||
using Lumina.Contracts.Responses.FileSystemManagement.Files;
|
||||
using Lumina.Domain.Core.Aggregates.FileSystemManagement.FileSystemManagementAggregate.Entities;
|
||||
using Lumina.Domain.Core.Aggregates.FileSystemManagement.FileSystemManagementAggregate.Services;
|
||||
using Mediator;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Core.FileManagement.Files.Queries.GetFiles;
|
||||
namespace Lumina.Application.Core.FileSystemManagement.Files.Queries.GetFiles;
|
||||
|
||||
/// <summary>
|
||||
/// Handler for the query to get all files.
|
||||
@@ -19,17 +18,14 @@ namespace Lumina.Application.Core.FileManagement.Files.Queries.GetFiles;
|
||||
public class GetFilesQueryHandler : IRequestHandler<GetFilesQuery, ErrorOr<IEnumerable<FileResponse>>>
|
||||
{
|
||||
private readonly IFileService _fileService;
|
||||
private readonly IMapper _mapper;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetFilesQueryHandler"/> class.
|
||||
/// </summary>
|
||||
/// <param name="fileService">Injected service for handling files.</param>
|
||||
/// <param name="mapper">Injected service for mapping objects.</param>
|
||||
public GetFilesQueryHandler(IFileService fileService, IMapper mapper)
|
||||
public GetFilesQueryHandler(IFileService fileService)
|
||||
{
|
||||
_fileService = fileService;
|
||||
_mapper = mapper;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -42,7 +38,7 @@ public class GetFilesQueryHandler : IRequestHandler<GetFilesQuery, ErrorOr<IEnum
|
||||
/// </returns>
|
||||
public ValueTask<ErrorOr<IEnumerable<FileResponse>>> Handle(GetFilesQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
ErrorOr<IEnumerable<File>> result = _fileService.GetFiles(request.Path, request.IncludeHiddenElements);
|
||||
return ValueTask.FromResult(result.Match(values => ErrorOrFactory.From(_mapper.Map<IEnumerable<FileResponse>>(values)), errors => errors));
|
||||
ErrorOr<IEnumerable<File>> result = _fileService.GetFiles(request.Path!, request.IncludeHiddenElements);
|
||||
return ValueTask.FromResult(result.Match(values => ErrorOrFactory.From(values.ToResponses()), errors => errors));
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -3,7 +3,7 @@ using FluentValidation;
|
||||
using Lumina.Domain.Common.Errors;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Core.FileManagement.Files.Queries.GetFiles;
|
||||
namespace Lumina.Application.Core.FileSystemManagement.Files.Queries.GetFiles;
|
||||
|
||||
/// <summary>
|
||||
/// Validates the needed validation rules for <see cref="GetFilesQuery"/>.
|
||||
@@ -15,6 +15,6 @@ public class GetFilesQueryValidator : AbstractValidator<GetFilesQuery>
|
||||
/// </summary>
|
||||
public GetFilesQueryValidator()
|
||||
{
|
||||
RuleFor(x => x.Path).NotEmpty().WithMessage(Errors.FileManagement.PathCannotBeEmpty.Code);
|
||||
RuleFor(x => x.Path).NotEmpty().WithMessage(Errors.FileSystemManagement.PathCannotBeEmpty.Description);
|
||||
}
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Contracts.Responses.FileSystemManagement.Common;
|
||||
using Mediator;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Core.FileSystemManagement.Files.Queries.GetTreeFiles;
|
||||
|
||||
/// <summary>
|
||||
/// Query for retrieving the list of files at a path.
|
||||
/// </summary>
|
||||
/// <param name="Path">The path for which to retrieve the list of files.</param>
|
||||
/// <param name="IncludeHiddenElements">Whether to include hidden files and directories or not.</param>
|
||||
[DebuggerDisplay("Path: {Path}")]
|
||||
public record GetTreeFilesQuery(
|
||||
string? Path,
|
||||
bool IncludeHiddenElements
|
||||
) : IRequest<ErrorOr<IEnumerable<FileSystemTreeNodeResponse>>>;
|
||||
+8
-12
@@ -1,17 +1,16 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Contracts.Responses.FileManagement;
|
||||
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Entities;
|
||||
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Services;
|
||||
using Mapster;
|
||||
using MapsterMapper;
|
||||
using Lumina.Application.Common.Mapping.FileSystemManagement.Files;
|
||||
using Lumina.Contracts.Responses.FileSystemManagement.Common;
|
||||
using Lumina.Domain.Core.Aggregates.FileSystemManagement.FileSystemManagementAggregate.Entities;
|
||||
using Lumina.Domain.Core.Aggregates.FileSystemManagement.FileSystemManagementAggregate.Services;
|
||||
using Mediator;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Core.FileManagement.Files.Queries.GetTreeFiles;
|
||||
namespace Lumina.Application.Core.FileSystemManagement.Files.Queries.GetTreeFiles;
|
||||
|
||||
/// <summary>
|
||||
/// Handler for the query to get all files.
|
||||
@@ -19,17 +18,14 @@ namespace Lumina.Application.Core.FileManagement.Files.Queries.GetTreeFiles;
|
||||
public class GetTreeFilesQueryHandler : IRequestHandler<GetTreeFilesQuery, ErrorOr<IEnumerable<FileSystemTreeNodeResponse>>>
|
||||
{
|
||||
private readonly IFileService _fileService;
|
||||
private readonly IMapper _mapper;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetTreeFilesQueryHandler"/> class.
|
||||
/// </summary>
|
||||
/// <param name="fileService">Injected service for handling files.</param>
|
||||
/// <param name="mapper">Injected service for mapping objects.</param>
|
||||
public GetTreeFilesQueryHandler(IFileService fileService, IMapper mapper)
|
||||
public GetTreeFilesQueryHandler(IFileService fileService)
|
||||
{
|
||||
_fileService = fileService;
|
||||
_mapper = mapper;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -42,7 +38,7 @@ public class GetTreeFilesQueryHandler : IRequestHandler<GetTreeFilesQuery, Error
|
||||
/// </returns>
|
||||
public ValueTask<ErrorOr<IEnumerable<FileSystemTreeNodeResponse>>> Handle(GetTreeFilesQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
ErrorOr<IEnumerable<File>> result = _fileService.GetFiles(request.Path, request.IncludeHiddenElements);
|
||||
return ValueTask.FromResult(result.Match(values => ErrorOrFactory.From(_mapper.Map<IEnumerable<FileSystemTreeNodeResponse>>(values)), errors => errors));
|
||||
ErrorOr<IEnumerable<File>> result = _fileService.GetFiles(request.Path!, request.IncludeHiddenElements);
|
||||
return ValueTask.FromResult(result.Match(values => ErrorOrFactory.From(values.ToFileSystemTreeNodeResponses()), errors => errors));
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -3,7 +3,7 @@ using FluentValidation;
|
||||
using Lumina.Domain.Common.Errors;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Core.FileManagement.Files.Queries.GetTreeFiles;
|
||||
namespace Lumina.Application.Core.FileSystemManagement.Files.Queries.GetTreeFiles;
|
||||
|
||||
/// <summary>
|
||||
/// Validates the needed validation rules for <see cref="GetTreeFilesQuery"/>.
|
||||
@@ -15,6 +15,6 @@ public class GetTreeFilesQueryValidator : AbstractValidator<GetTreeFilesQuery>
|
||||
/// </summary>
|
||||
public GetTreeFilesQueryValidator()
|
||||
{
|
||||
RuleFor(x => x.Path).NotEmpty().WithMessage(Errors.FileManagement.PathCannotBeEmpty.Code);
|
||||
RuleFor(x => x.Path).NotEmpty().WithMessage(Errors.FileSystemManagement.PathCannotBeEmpty.Description);
|
||||
}
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Contracts.Responses.FileSystemManagement.Path;
|
||||
using Mediator;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Core.FileSystemManagement.Paths.Commands.CombinePath;
|
||||
|
||||
/// <summary>
|
||||
/// Command for combining two file system path.
|
||||
/// </summary>
|
||||
/// <param name="OriginalPath">The path to combine to.</param>
|
||||
/// <param name="NewPath">The path to combine with.</param>
|
||||
[DebuggerDisplay("OriginalPath: {OriginalPath}, NewPath: {NewPath}")]
|
||||
public record CombinePathCommand(
|
||||
string? OriginalPath,
|
||||
string? NewPath
|
||||
) : IRequest<ErrorOr<PathSegmentResponse>>;
|
||||
+7
-7
@@ -1,14 +1,14 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Application.Core.FileManagement.Paths.Commands.SplitPath;
|
||||
using Lumina.Contracts.Responses.FileManagement;
|
||||
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Services;
|
||||
using Lumina.Application.Core.FileSystemManagement.Paths.Commands.SplitPath;
|
||||
using Lumina.Contracts.Responses.FileSystemManagement.Path;
|
||||
using Lumina.Domain.Core.Aggregates.FileSystemManagement.FileSystemManagementAggregate.Services;
|
||||
using Mediator;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Core.FileManagement.Paths.Commands.CombinePath;
|
||||
namespace Lumina.Application.Core.FileSystemManagement.Paths.Commands.CombinePath;
|
||||
|
||||
/// <summary>
|
||||
/// Handler for the command to split a file system path.
|
||||
@@ -36,7 +36,7 @@ public class CombinePathCommandHandler : IRequestHandler<CombinePathCommand, Err
|
||||
/// </returns>
|
||||
public ValueTask<ErrorOr<PathSegmentResponse>> Handle(CombinePathCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
ErrorOr<string> result = _pathService.CombinePath(request.OriginalPath, request.NewPath);
|
||||
ErrorOr<string> result = _pathService.CombinePath(request.OriginalPath!, request.NewPath!);
|
||||
return ValueTask.FromResult(result.Match(values => ErrorOrFactory.From(new PathSegmentResponse(result.Value)), errors => errors));
|
||||
}
|
||||
}
|
||||
}
|
||||
+5
-5
@@ -1,9 +1,9 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FluentValidation;
|
||||
using Lumina.Domain.Common.Errors;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Core.FileManagement.Paths.Commands.CombinePath;
|
||||
namespace Lumina.Application.Core.FileSystemManagement.Paths.Commands.CombinePath;
|
||||
|
||||
/// <summary>
|
||||
/// Validates the needed validation rules for <see cref="CombinePathCommand"/>.
|
||||
@@ -15,7 +15,7 @@ public class CombinePathCommandValidator : AbstractValidator<CombinePathCommand>
|
||||
/// </summary>
|
||||
public CombinePathCommandValidator()
|
||||
{
|
||||
RuleFor(x => x.OriginalPath).NotEmpty().WithMessage(Errors.FileManagement.PathCannotBeEmpty.Code);
|
||||
RuleFor(x => x.NewPath).NotEmpty().WithMessage(Errors.FileManagement.PathCannotBeEmpty.Code);
|
||||
RuleFor(x => x.OriginalPath).NotEmpty().WithMessage(Errors.FileSystemManagement.PathCannotBeEmpty.Description);
|
||||
RuleFor(x => x.NewPath).NotEmpty().WithMessage(Errors.FileSystemManagement.PathCannotBeEmpty.Description);
|
||||
}
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Contracts.Responses.FileSystemManagement.Path;
|
||||
using Mediator;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Core.FileSystemManagement.Paths.Commands.SplitPath;
|
||||
|
||||
/// <summary>
|
||||
/// Command for splitting a file system path.
|
||||
/// </summary>
|
||||
/// <param name="Path">The file system path to split.</param>
|
||||
[DebuggerDisplay("Path: {Path}")]
|
||||
public record SplitPathCommand(
|
||||
string? Path
|
||||
) : IRequest<ErrorOr<IEnumerable<PathSegmentResponse>>>;
|
||||
+8
-11
@@ -1,16 +1,16 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Contracts.Responses.FileManagement;
|
||||
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Services;
|
||||
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.ValueObjects;
|
||||
using MapsterMapper;
|
||||
using Lumina.Application.Common.Mapping.FileSystemManagement.Paths;
|
||||
using Lumina.Contracts.Responses.FileSystemManagement.Path;
|
||||
using Lumina.Domain.Core.Aggregates.FileSystemManagement.FileSystemManagementAggregate.Services;
|
||||
using Lumina.Domain.Core.Aggregates.FileSystemManagement.FileSystemManagementAggregate.ValueObjects;
|
||||
using Mediator;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Core.FileManagement.Paths.Commands.SplitPath;
|
||||
namespace Lumina.Application.Core.FileSystemManagement.Paths.Commands.SplitPath;
|
||||
|
||||
/// <summary>
|
||||
/// Handler for the command to split a file system path.
|
||||
@@ -18,17 +18,14 @@ namespace Lumina.Application.Core.FileManagement.Paths.Commands.SplitPath;
|
||||
public class SplitPathCommandHandler : IRequestHandler<SplitPathCommand, ErrorOr<IEnumerable<PathSegmentResponse>>>
|
||||
{
|
||||
private readonly IPathService _pathService;
|
||||
private readonly IMapper _mapper;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="SplitPathCommandHandler"/> class.
|
||||
/// </summary>
|
||||
/// <param name="pathService">Injected service for handling file system paths.</param>
|
||||
/// <param name="mapper">Injected service for mapping objects.</param>
|
||||
public SplitPathCommandHandler(IPathService pathService, IMapper mapper)
|
||||
public SplitPathCommandHandler(IPathService pathService)
|
||||
{
|
||||
_pathService = pathService;
|
||||
_mapper = mapper;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -41,7 +38,7 @@ public class SplitPathCommandHandler : IRequestHandler<SplitPathCommand, ErrorOr
|
||||
/// </returns>
|
||||
public ValueTask<ErrorOr<IEnumerable<PathSegmentResponse>>> Handle(SplitPathCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
ErrorOr<IEnumerable<PathSegment>> result = _pathService.ParsePath(request.Path);
|
||||
return ValueTask.FromResult(result.Match(values => ErrorOrFactory.From(_mapper.Map<IEnumerable<PathSegmentResponse>>(values)), errors => errors));
|
||||
ErrorOr<IEnumerable<PathSegment>> result = _pathService.ParsePath(request.Path!);
|
||||
return ValueTask.FromResult(result.Match(values => ErrorOrFactory.From(values.ToResponses()), errors => errors));
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -3,7 +3,7 @@ using FluentValidation;
|
||||
using Lumina.Domain.Common.Errors;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Core.FileManagement.Paths.Commands.SplitPath;
|
||||
namespace Lumina.Application.Core.FileSystemManagement.Paths.Commands.SplitPath;
|
||||
|
||||
/// <summary>
|
||||
/// Validates the needed validation rules for <see cref="SplitPathCommand"/>.
|
||||
@@ -15,6 +15,6 @@ public class SplitPathCommandValidator : AbstractValidator<SplitPathCommand>
|
||||
/// </summary>
|
||||
public SplitPathCommandValidator()
|
||||
{
|
||||
RuleFor(x => x.Path).NotEmpty().WithMessage(Errors.FileManagement.PathCannotBeEmpty.Code);
|
||||
RuleFor(x => x.Path).NotEmpty().WithMessage(Errors.FileSystemManagement.PathCannotBeEmpty.Description);
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.Responses.FileSystemManagement.Path;
|
||||
using Mediator;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Core.FileSystemManagement.Paths.Queries.CheckPathExists;
|
||||
|
||||
/// <summary>
|
||||
/// Query for checking the existence of a file system path.
|
||||
/// </summary>
|
||||
/// <param name="Path">The path for which to check the existence of.</param>
|
||||
/// <param name="IncludeHiddenElements">Whether to include hidden file system elements or not.</param>
|
||||
[DebuggerDisplay("Path: {Path}, IncludeHiddenElements: {IncludeHiddenElements}")]
|
||||
public record CheckPathExistsQuery(
|
||||
string? Path,
|
||||
bool IncludeHiddenElements
|
||||
) : IRequest<PathExistsResponse>;
|
||||
+4
-4
@@ -1,12 +1,12 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.Responses.FileManagement;
|
||||
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Services;
|
||||
using Lumina.Contracts.Responses.FileSystemManagement.Path;
|
||||
using Lumina.Domain.Core.Aggregates.FileSystemManagement.FileSystemManagementAggregate.Services;
|
||||
using Mediator;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Core.FileManagement.Paths.Queries.CheckPathExists;
|
||||
namespace Lumina.Application.Core.FileSystemManagement.Paths.Queries.CheckPathExists;
|
||||
|
||||
/// <summary>
|
||||
/// Handler for the query to check the existence a file system path.
|
||||
@@ -34,6 +34,6 @@ public class CheckPathExistsQueryHandler : IRequestHandler<CheckPathExistsQuery,
|
||||
/// </returns>
|
||||
public ValueTask<PathExistsResponse> Handle(CheckPathExistsQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
return ValueTask.FromResult(new PathExistsResponse(_pathService.Exists(request.Path, request.IncludeHiddenElements)));
|
||||
return ValueTask.FromResult(new PathExistsResponse(_pathService.Exists(request.Path!, request.IncludeHiddenElements)));
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -3,7 +3,7 @@ using FluentValidation;
|
||||
using Lumina.Domain.Common.Errors;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Core.FileManagement.Paths.Queries.CheckPathExists;
|
||||
namespace Lumina.Application.Core.FileSystemManagement.Paths.Queries.CheckPathExists;
|
||||
|
||||
/// <summary>
|
||||
/// Validates the needed validation rules for <see cref="CheckPathExistsQuery"/>.
|
||||
@@ -15,6 +15,6 @@ public class CheckPathExistsQueryValidator : AbstractValidator<CheckPathExistsQu
|
||||
/// </summary>
|
||||
public CheckPathExistsQueryValidator()
|
||||
{
|
||||
RuleFor(x => x.Path).NotEmpty().WithMessage(Errors.FileManagement.PathCannotBeEmpty.Code);
|
||||
RuleFor(x => x.Path).NotEmpty().WithMessage(Errors.FileSystemManagement.PathCannotBeEmpty.Description);
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Contracts.Responses.FileSystemManagement.Path;
|
||||
using Mediator;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Core.FileSystemManagement.Paths.Queries.GetPathParent;
|
||||
|
||||
/// <summary>
|
||||
/// Query for retrieving the parent of a file system path.
|
||||
/// </summary>
|
||||
/// <param name="Path">The path for which to get the parent.</param>
|
||||
[DebuggerDisplay("Path: {Path}")]
|
||||
public record GetPathParentQuery(
|
||||
string? Path
|
||||
) : IRequest<ErrorOr<IEnumerable<PathSegmentResponse>>>;
|
||||
+8
-11
@@ -1,16 +1,16 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Contracts.Responses.FileManagement;
|
||||
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Services;
|
||||
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.ValueObjects;
|
||||
using MapsterMapper;
|
||||
using Lumina.Application.Common.Mapping.FileSystemManagement.Paths;
|
||||
using Lumina.Contracts.Responses.FileSystemManagement.Path;
|
||||
using Lumina.Domain.Core.Aggregates.FileSystemManagement.FileSystemManagementAggregate.Services;
|
||||
using Lumina.Domain.Core.Aggregates.FileSystemManagement.FileSystemManagementAggregate.ValueObjects;
|
||||
using Mediator;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Core.FileManagement.Paths.Queries.GetPathParent;
|
||||
namespace Lumina.Application.Core.FileSystemManagement.Paths.Queries.GetPathParent;
|
||||
|
||||
/// <summary>
|
||||
/// Handler for the query to get the parent of a file system path.
|
||||
@@ -18,17 +18,14 @@ namespace Lumina.Application.Core.FileManagement.Paths.Queries.GetPathParent;
|
||||
public class GetPathParentQueryHandler : IRequestHandler<GetPathParentQuery, ErrorOr<IEnumerable<PathSegmentResponse>>>
|
||||
{
|
||||
private readonly IPathService _pathService;
|
||||
private readonly IMapper _mapper;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetPathParentQueryHandler"/> class.
|
||||
/// </summary>
|
||||
/// <param name="pathService">Injected service for managing file system paths.</param>
|
||||
/// <param name="mapper">Injected service for mapping objects.</param>
|
||||
public GetPathParentQueryHandler(IPathService pathService, IMapper mapper)
|
||||
public GetPathParentQueryHandler(IPathService pathService)
|
||||
{
|
||||
_pathService = pathService;
|
||||
_mapper = mapper;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -41,7 +38,7 @@ public class GetPathParentQueryHandler : IRequestHandler<GetPathParentQuery, Err
|
||||
/// </returns>
|
||||
public ValueTask<ErrorOr<IEnumerable<PathSegmentResponse>>> Handle(GetPathParentQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
ErrorOr<IEnumerable<PathSegment>> result = _pathService.GoUpOneLevel(request.Path);
|
||||
return ValueTask.FromResult(result.Match(values => ErrorOrFactory.From(_mapper.Map<IEnumerable<PathSegmentResponse>>(values)), errors => errors));
|
||||
ErrorOr<IEnumerable<PathSegment>> result = _pathService.GoUpOneLevel(request.Path!);
|
||||
return ValueTask.FromResult(result.Match(values => ErrorOrFactory.From(values.ToResponses()), errors => errors));
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -3,7 +3,7 @@ using FluentValidation;
|
||||
using Lumina.Domain.Common.Errors;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Core.FileManagement.Paths.Queries.GetPathParent;
|
||||
namespace Lumina.Application.Core.FileSystemManagement.Paths.Queries.GetPathParent;
|
||||
|
||||
/// <summary>
|
||||
/// Validates the needed validation rules for <see cref="GetPathParentQuery"/>.
|
||||
@@ -15,6 +15,6 @@ public class GetPathParentQueryValidator : AbstractValidator<GetPathParentQuery>
|
||||
/// </summary>
|
||||
public GetPathParentQueryValidator()
|
||||
{
|
||||
RuleFor(x => x.Path).NotEmpty().WithMessage(Errors.FileManagement.PathCannotBeEmpty.Code);
|
||||
RuleFor(x => x.Path).NotEmpty().WithMessage(Errors.FileSystemManagement.PathCannotBeEmpty.Description);
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Contracts.Responses.FileSystemManagement.Path;
|
||||
using Mediator;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Core.FileSystemManagement.Paths.Queries.GetPathRoot;
|
||||
|
||||
/// <summary>
|
||||
/// Query for retrieving the root of a path.
|
||||
/// </summary>
|
||||
/// <param name="Path">The path for which to get the path root.</param>
|
||||
[DebuggerDisplay("Path: {Path}")]
|
||||
public record GetPathRootQuery(
|
||||
string? Path
|
||||
) : IRequest<ErrorOr<PathSegmentResponse>>;
|
||||
+8
-11
@@ -1,15 +1,15 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Contracts.Responses.FileManagement;
|
||||
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Services;
|
||||
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.ValueObjects;
|
||||
using MapsterMapper;
|
||||
using Lumina.Application.Common.Mapping.FileSystemManagement.Paths;
|
||||
using Lumina.Contracts.Responses.FileSystemManagement.Path;
|
||||
using Lumina.Domain.Core.Aggregates.FileSystemManagement.FileSystemManagementAggregate.Services;
|
||||
using Lumina.Domain.Core.Aggregates.FileSystemManagement.FileSystemManagementAggregate.ValueObjects;
|
||||
using Mediator;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Core.FileManagement.Paths.Queries.GetPathRoot;
|
||||
namespace Lumina.Application.Core.FileSystemManagement.Paths.Queries.GetPathRoot;
|
||||
|
||||
/// <summary>
|
||||
/// Handler for the query to get the root of a file system path.
|
||||
@@ -17,17 +17,14 @@ namespace Lumina.Application.Core.FileManagement.Paths.Queries.GetPathRoot;
|
||||
public class GetPathRootQueryHandler : IRequestHandler<GetPathRootQuery, ErrorOr<PathSegmentResponse>>
|
||||
{
|
||||
private readonly IPathService _pathService;
|
||||
private readonly IMapper _mapper;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetPathRootQueryHandler"/> class.
|
||||
/// </summary>
|
||||
/// <param name="pathService">Injected service for managing file system paths.</param>
|
||||
/// <param name="mapper">Injected service for mapping objects.</param>
|
||||
public GetPathRootQueryHandler(IPathService pathService, IMapper mapper)
|
||||
public GetPathRootQueryHandler(IPathService pathService)
|
||||
{
|
||||
_pathService = pathService;
|
||||
_mapper = mapper;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -38,7 +35,7 @@ public class GetPathRootQueryHandler : IRequestHandler<GetPathRootQuery, ErrorOr
|
||||
/// <returns>The root of the specified path.</returns>
|
||||
public ValueTask<ErrorOr<PathSegmentResponse>> Handle(GetPathRootQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
ErrorOr<PathSegment> result = _pathService.GetPathRoot(request.Path);
|
||||
return ValueTask.FromResult(result.Match(values => ErrorOrFactory.From(_mapper.Map<PathSegmentResponse>(values)), errors => errors));
|
||||
ErrorOr<PathSegment> result = _pathService.GetPathRoot(request.Path!);
|
||||
return ValueTask.FromResult(result.Match(values => ErrorOrFactory.From(values.ToResponse()), errors => errors));
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -3,7 +3,7 @@ using FluentValidation;
|
||||
using Lumina.Domain.Common.Errors;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Core.FileManagement.Paths.Queries.GetPathRoot;
|
||||
namespace Lumina.Application.Core.FileSystemManagement.Paths.Queries.GetPathRoot;
|
||||
|
||||
/// <summary>
|
||||
/// Validates the needed validation rules for <see cref="GetPathRootQuery"/>.
|
||||
@@ -15,6 +15,6 @@ public class GetPathRootQueryValidator : AbstractValidator<GetPathRootQuery>
|
||||
/// </summary>
|
||||
public GetPathRootQueryValidator()
|
||||
{
|
||||
RuleFor(x => x.Path).NotEmpty().WithMessage(Errors.FileManagement.PathCannotBeEmpty.Code);
|
||||
RuleFor(x => x.Path).NotEmpty().WithMessage(Errors.FileSystemManagement.PathCannotBeEmpty.Description);
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,9 +1,9 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.Responses.FileManagement;
|
||||
using Lumina.Contracts.Responses.FileSystemManagement.Path;
|
||||
using Mediator;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Core.FileManagement.Paths.Queries.GetPathSeparator;
|
||||
namespace Lumina.Application.Core.FileSystemManagement.Paths.Queries.GetPathSeparator;
|
||||
|
||||
/// <summary>
|
||||
/// Query for retrieving the file system path separator.
|
||||
+3
-3
@@ -1,12 +1,12 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.Responses.FileManagement;
|
||||
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Services;
|
||||
using Lumina.Contracts.Responses.FileSystemManagement.Path;
|
||||
using Lumina.Domain.Core.Aggregates.FileSystemManagement.FileSystemManagementAggregate.Services;
|
||||
using Mediator;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Core.FileManagement.Paths.Queries.GetPathSeparator;
|
||||
namespace Lumina.Application.Core.FileSystemManagement.Paths.Queries.GetPathSeparator;
|
||||
|
||||
/// <summary>
|
||||
/// Handler for the query to get the path separator character of a file system path.
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.Responses.FileSystemManagement.Path;
|
||||
using Mediator;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Core.FileSystemManagement.Paths.Queries.ValidatePath;
|
||||
|
||||
/// <summary>
|
||||
/// Query for validating a path.
|
||||
/// </summary>
|
||||
/// <param name="Path">The path to be validated.</param>
|
||||
[DebuggerDisplay("Path: {Path}")]
|
||||
public record ValidatePathQuery(
|
||||
string? Path
|
||||
) : IRequest<PathValidResponse>;
|
||||
+6
-6
@@ -1,12 +1,12 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.Responses.FileManagement;
|
||||
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Services;
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.Responses.FileSystemManagement.Path;
|
||||
using Lumina.Domain.Core.Aggregates.FileSystemManagement.FileSystemManagementAggregate.Services;
|
||||
using Mediator;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Core.FileManagement.Paths.Queries.ValidatePath;
|
||||
namespace Lumina.Application.Core.FileSystemManagement.Paths.Queries.ValidatePath;
|
||||
|
||||
/// <summary>
|
||||
/// Handler for the query to validate a file system path.
|
||||
@@ -34,6 +34,6 @@ public class ValidatePathQueryHandler : IRequestHandler<ValidatePathQuery, PathV
|
||||
/// </returns>
|
||||
public ValueTask<PathValidResponse> Handle(ValidatePathQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
return ValueTask.FromResult(new PathValidResponse(_pathService.IsValidPath(request.Path)));
|
||||
return ValueTask.FromResult(new PathValidResponse(_pathService.IsValidPath(request.Path!)));
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -3,7 +3,7 @@ using FluentValidation;
|
||||
using Lumina.Domain.Common.Errors;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Core.FileManagement.Paths.Queries.ValidatePath;
|
||||
namespace Lumina.Application.Core.FileSystemManagement.Paths.Queries.ValidatePath;
|
||||
|
||||
/// <summary>
|
||||
/// Validates the needed validation rules for <see cref="ValidatePathQuery"/>.
|
||||
@@ -15,6 +15,6 @@ public class ValidatePathQueryValidator : AbstractValidator<ValidatePathQuery>
|
||||
/// </summary>
|
||||
public ValidatePathQueryValidator()
|
||||
{
|
||||
RuleFor(x => x.Path).NotEmpty().WithMessage(Errors.FileManagement.PathCannotBeEmpty.Code);
|
||||
RuleFor(x => x.Path).NotEmpty().WithMessage(Errors.FileSystemManagement.PathCannotBeEmpty.Description);
|
||||
}
|
||||
}
|
||||
+8
-3
@@ -1,14 +1,19 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Contracts.Responses.FileManagement;
|
||||
using Lumina.Contracts.Responses.FileSystemManagement.Thumbnails;
|
||||
using Mediator;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Core.FileManagement.Thumbnails.Queries.GetThumbnail;
|
||||
namespace Lumina.Application.Core.FileSystemManagement.Thumbnails.Queries.GetThumbnail;
|
||||
|
||||
/// <summary>
|
||||
/// Query for retrieving the thumbnail of a file at a path.
|
||||
/// </summary>
|
||||
/// <param name="Path">The file path of the image to generate the thumbnail from.</param>
|
||||
/// <param name="Quality">The desired quality of the thumbnail image (e.g., resolution or compression level).</param>
|
||||
public record GetThumbnailQuery(string Path, int Quality) : IRequest<ErrorOr<ThumbnailResponse>>;
|
||||
[DebuggerDisplay("Path: {Path}")]
|
||||
public record GetThumbnailQuery(
|
||||
string? Path,
|
||||
int Quality
|
||||
) : IRequest<ErrorOr<ThumbnailResponse>>;
|
||||
+8
-11
@@ -1,15 +1,15 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Contracts.Responses.FileManagement;
|
||||
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Services;
|
||||
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.ValueObjects;
|
||||
using MapsterMapper;
|
||||
using Lumina.Application.Common.Mapping.FileSystemManagement.Thumbnails;
|
||||
using Lumina.Contracts.Responses.FileSystemManagement.Thumbnails;
|
||||
using Lumina.Domain.Core.Aggregates.FileSystemManagement.FileSystemManagementAggregate.Services;
|
||||
using Lumina.Domain.Core.Aggregates.FileSystemManagement.FileSystemManagementAggregate.ValueObjects;
|
||||
using Mediator;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Core.FileManagement.Thumbnails.Queries.GetThumbnail;
|
||||
namespace Lumina.Application.Core.FileSystemManagement.Thumbnails.Queries.GetThumbnail;
|
||||
|
||||
/// <summary>
|
||||
/// Handler for the query to get the file thumbnail.
|
||||
@@ -17,17 +17,14 @@ namespace Lumina.Application.Core.FileManagement.Thumbnails.Queries.GetThumbnail
|
||||
public class GetThumbnailQueryHandler : IRequestHandler<GetThumbnailQuery, ErrorOr<ThumbnailResponse>>
|
||||
{
|
||||
private readonly IThumbnailService _thumbnailsService;
|
||||
private readonly IMapper _mapper;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetThumbnailQueryHandler"/> class.
|
||||
/// </summary>
|
||||
/// <param name="thumbnailsService">Injected service for handling thumbnails.</param>
|
||||
/// <param name="mapper">Injected service for mapping objects.</param>
|
||||
public GetThumbnailQueryHandler(IThumbnailService thumbnailsService, IMapper mapper)
|
||||
public GetThumbnailQueryHandler(IThumbnailService thumbnailsService)
|
||||
{
|
||||
_thumbnailsService = thumbnailsService;
|
||||
_mapper = mapper;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -38,7 +35,7 @@ public class GetThumbnailQueryHandler : IRequestHandler<GetThumbnailQuery, Error
|
||||
/// <returns>An <see cref="ErrorOr{T}"/> containing either a thumbnail, or an error.</returns>
|
||||
public async ValueTask<ErrorOr<ThumbnailResponse>> Handle(GetThumbnailQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
ErrorOr<Thumbnail> result = await _thumbnailsService.GetThumbnailAsync(request.Path, request.Quality, cancellationToken);
|
||||
return await ValueTask.FromResult(result.Match(values => ErrorOrFactory.From(_mapper.Map<ThumbnailResponse>(values)), errors => errors));
|
||||
ErrorOr<Thumbnail> result = await _thumbnailsService.GetThumbnailAsync(request.Path!, request.Quality, cancellationToken);
|
||||
return await ValueTask.FromResult(result.Match(value => ErrorOrFactory.From(value.ToResponse()), errors => errors));
|
||||
}
|
||||
}
|
||||
Loaded 100 of 519 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user