mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 05:11:10 +00:00
Refactors directory structure for commands and queries
This commit is contained in:
1 parent
35fe931173
commit
712a0f2b27
54 files changed
+111
-101
No files matched your search
+1
-1
@@ -5,7 +5,7 @@ using Mediator;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
namespace Lumina.Application.Core.FileManagement.Directories.Queries;
|
namespace Lumina.Application.Core.FileManagement.Directories.Queries.GetDirectories;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Query for retrieving the list of directories at a path.
|
/// Query for retrieving the list of directories at a path.
|
||||||
+2
-2
@@ -11,7 +11,7 @@ using System.Threading;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
namespace Lumina.Application.Core.FileManagement.Directories.Queries;
|
namespace Lumina.Application.Core.FileManagement.Directories.Queries.GetDirectories;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handler for the query to get all directories.
|
/// Handler for the query to get all directories.
|
||||||
@@ -44,7 +44,7 @@ public class GetDirectoriesQueryHandler : IRequestHandler<GetDirectoriesQuery, E
|
|||||||
/// </returns>
|
/// </returns>
|
||||||
public ValueTask<ErrorOr<IEnumerable<DirectoryResponse>>> Handle(GetDirectoriesQuery request, CancellationToken cancellationToken)
|
public ValueTask<ErrorOr<IEnumerable<DirectoryResponse>>> Handle(GetDirectoriesQuery request, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
ErrorOr<IEnumerable<Directory>> result = _directoryService.GetSubdirectories(request.Path);
|
var result = _directoryService.GetSubdirectories(request.Path);
|
||||||
return ValueTask.FromResult(result.Match(values => ErrorOrFactory.From(result.Value.Adapt<IEnumerable<DirectoryResponse>>()), errors => errors));
|
return ValueTask.FromResult(result.Match(values => ErrorOrFactory.From(result.Value.Adapt<IEnumerable<DirectoryResponse>>()), errors => errors));
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
+1
-1
@@ -3,7 +3,7 @@ using FluentValidation;
|
|||||||
using Lumina.Domain.Common.Errors;
|
using Lumina.Domain.Common.Errors;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
namespace Lumina.Application.Core.FileManagement.Directories.Queries;
|
namespace Lumina.Application.Core.FileManagement.Directories.Queries.GetDirectories;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Validates the needed validation rules for <see cref="GetDirectoriesQuery"/>.
|
/// Validates the needed validation rules for <see cref="GetDirectoriesQuery"/>.
|
||||||
+1
-1
@@ -5,7 +5,7 @@ using Mediator;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
namespace Lumina.Application.Core.FileManagement.Directories.Queries;
|
namespace Lumina.Application.Core.FileManagement.Directories.Queries.GetDirectoryTree;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Query for retrieving the tree of directories of a path.
|
/// Query for retrieving the tree of directories of a path.
|
||||||
+19
-19
@@ -14,7 +14,7 @@ using System.Threading;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
namespace Lumina.Application.Core.FileManagement.Directories.Queries;
|
namespace Lumina.Application.Core.FileManagement.Directories.Queries.GetDirectoryTree;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handler for the query to get a directory tree.
|
/// Handler for the query to get a directory tree.
|
||||||
@@ -56,24 +56,24 @@ public class GetDirectoryTreeQueryHandler : IRequestHandler<GetDirectoryTreeQuer
|
|||||||
{
|
{
|
||||||
List<FileSystemTreeNodeResponse> result = [];
|
List<FileSystemTreeNodeResponse> result = [];
|
||||||
// retrieve the list of drives
|
// retrieve the list of drives
|
||||||
ErrorOr<IEnumerable<FileSystemTreeNodeResponse>> getDrivesResult = GetDrives();
|
var getDrivesResult = GetDrives();
|
||||||
if (getDrivesResult.IsError)
|
if (getDrivesResult.IsError)
|
||||||
return getDrivesResult.Errors;
|
return getDrivesResult.Errors;
|
||||||
result.AddRange(getDrivesResult.Value);
|
result.AddRange(getDrivesResult.Value);
|
||||||
|
|
||||||
ErrorOr<IEnumerable<PathSegment>> pathPartsResults = _pathService.ParsePath(request.Path);
|
var pathPartsResults = _pathService.ParsePath(request.Path);
|
||||||
if (pathPartsResults.IsError)
|
if (pathPartsResults.IsError)
|
||||||
return pathPartsResults.Errors;
|
return pathPartsResults.Errors;
|
||||||
|
|
||||||
List<PathSegment> pathParts = pathPartsResults.Value.ToList();
|
var pathParts = pathPartsResults.Value.ToList();
|
||||||
string currentPath = pathParts[0].Name;
|
var currentPath = pathParts[0].Name;
|
||||||
|
|
||||||
ErrorOr<IEnumerable<FileSystemTreeNodeResponse>> buildDirectoryTreeResult = BuildDirectoryTree(result, pathParts, out FileSystemTreeNodeResponse currentNode);
|
var buildDirectoryTreeResult = BuildDirectoryTree(result, pathParts, out var currentNode);
|
||||||
if (buildDirectoryTreeResult.IsError)
|
if (buildDirectoryTreeResult.IsError)
|
||||||
return buildDirectoryTreeResult.Errors;
|
return buildDirectoryTreeResult.Errors;
|
||||||
|
|
||||||
// add subdirectories of the last directory node
|
// add subdirectories of the last directory node
|
||||||
ErrorOr<Success> loadChildrenResult = LoadChildren(currentNode, request.IncludeFiles);
|
var loadChildrenResult = LoadChildren(currentNode, request.IncludeFiles);
|
||||||
if (loadChildrenResult.IsError)
|
if (loadChildrenResult.IsError)
|
||||||
return loadChildrenResult.Errors;
|
return loadChildrenResult.Errors;
|
||||||
return await ValueTask.FromResult(result);
|
return await ValueTask.FromResult(result);
|
||||||
@@ -87,7 +87,7 @@ public class GetDirectoryTreeQueryHandler : IRequestHandler<GetDirectoryTreeQuer
|
|||||||
/// </returns>
|
/// </returns>
|
||||||
private ErrorOr<IEnumerable<FileSystemTreeNodeResponse>> GetDrives()
|
private ErrorOr<IEnumerable<FileSystemTreeNodeResponse>> GetDrives()
|
||||||
{
|
{
|
||||||
ErrorOr<IEnumerable<FileSystemItem>> driveResult = _driveService.GetDrives();
|
var driveResult = _driveService.GetDrives();
|
||||||
if (driveResult.IsError)
|
if (driveResult.IsError)
|
||||||
return driveResult.Errors;
|
return driveResult.Errors;
|
||||||
return ErrorOrFactory.From(driveResult.Value.Adapt<IEnumerable<FileSystemTreeNodeResponse>>());
|
return ErrorOrFactory.From(driveResult.Value.Adapt<IEnumerable<FileSystemTreeNodeResponse>>());
|
||||||
@@ -104,21 +104,21 @@ public class GetDirectoryTreeQueryHandler : IRequestHandler<GetDirectoryTreeQuer
|
|||||||
private ErrorOr<IEnumerable<FileSystemTreeNodeResponse>> BuildDirectoryTree(List<FileSystemTreeNodeResponse> drives, List<PathSegment> pathParts, out FileSystemTreeNodeResponse currentNode)
|
private ErrorOr<IEnumerable<FileSystemTreeNodeResponse>> BuildDirectoryTree(List<FileSystemTreeNodeResponse> drives, List<PathSegment> pathParts, out FileSystemTreeNodeResponse currentNode)
|
||||||
{
|
{
|
||||||
// find the root drive that matches the first part of the path
|
// find the root drive that matches the first part of the path
|
||||||
FileSystemTreeNodeResponse drive = drives.First(d => d.Name.Contains(pathParts[0].Name));
|
var drive = drives.First(d => d.Name.Contains(pathParts[0].Name));
|
||||||
drive.IsExpanded = true;
|
drive.IsExpanded = true;
|
||||||
currentNode = drive;
|
currentNode = drive;
|
||||||
string currentPath = pathParts[0].Name;
|
var currentPath = pathParts[0].Name;
|
||||||
|
|
||||||
// traverse the remaining path parts to build the tree structure
|
// traverse the remaining path parts to build the tree structure
|
||||||
for (int i = 1; i < pathParts.Count; i++)
|
for (var i = 1; i < pathParts.Count; i++)
|
||||||
{
|
{
|
||||||
ErrorOr<string> combinedPathResult = _pathService.CombinePath(currentPath, pathParts[i].Name);
|
var combinedPathResult = _pathService.CombinePath(currentPath, pathParts[i].Name);
|
||||||
if (combinedPathResult.IsError)
|
if (combinedPathResult.IsError)
|
||||||
return combinedPathResult.Errors;
|
return combinedPathResult.Errors;
|
||||||
|
|
||||||
currentPath = combinedPathResult.Value;
|
currentPath = combinedPathResult.Value;
|
||||||
// create a new node for the directory and add it as a child of the current node
|
// create a new node for the directory and add it as a child of the current node
|
||||||
FileSystemTreeNodeResponse newNode = new FileSystemTreeNodeResponse
|
var newNode = new FileSystemTreeNodeResponse
|
||||||
{
|
{
|
||||||
Path = currentPath,
|
Path = currentPath,
|
||||||
Name = pathParts[i].Name,
|
Name = pathParts[i].Name,
|
||||||
@@ -140,13 +140,13 @@ public class GetDirectoryTreeQueryHandler : IRequestHandler<GetDirectoryTreeQuer
|
|||||||
private ErrorOr<Success> LoadChildren(FileSystemTreeNodeResponse node, bool includeFiles)
|
private ErrorOr<Success> LoadChildren(FileSystemTreeNodeResponse node, bool includeFiles)
|
||||||
{
|
{
|
||||||
// get subdirectories under the current node's path
|
// get subdirectories under the current node's path
|
||||||
ErrorOr<IEnumerable<Directory>> subDirectoriesResult = _directoryService.GetSubdirectories(node.Path);
|
var subDirectoriesResult = _directoryService.GetSubdirectories(node.Path);
|
||||||
if (subDirectoriesResult.IsError)
|
if (subDirectoriesResult.IsError)
|
||||||
return subDirectoriesResult.Errors;
|
return subDirectoriesResult.Errors;
|
||||||
// add each subdirectory as a child node of the current directory
|
// add each subdirectory as a child node of the current directory
|
||||||
foreach (Directory subDirectory in subDirectoriesResult.Value)
|
foreach (var subDirectory in subDirectoriesResult.Value)
|
||||||
{
|
{
|
||||||
FileSystemTreeNodeResponse subDirNode = new FileSystemTreeNodeResponse
|
var subDirNode = new FileSystemTreeNodeResponse
|
||||||
{
|
{
|
||||||
Name = subDirectory.Name,
|
Name = subDirectory.Name,
|
||||||
Path = subDirectory.Id.Path,
|
Path = subDirectory.Id.Path,
|
||||||
@@ -159,13 +159,13 @@ public class GetDirectoryTreeQueryHandler : IRequestHandler<GetDirectoryTreeQuer
|
|||||||
if (includeFiles)
|
if (includeFiles)
|
||||||
{
|
{
|
||||||
// get files under the current node's path
|
// get files under the current node's path
|
||||||
ErrorOr<IEnumerable<File>> filesResult = _fileService.GetFiles(node.Path);
|
var filesResult = _fileService.GetFiles(node.Path);
|
||||||
if (filesResult.IsError)
|
if (filesResult.IsError)
|
||||||
return filesResult.Errors;
|
return filesResult.Errors;
|
||||||
// add each file as a child node of the current directory
|
// add each file as a child node of the current directory
|
||||||
foreach (File file in filesResult.Value)
|
foreach (var file in filesResult.Value)
|
||||||
{
|
{
|
||||||
FileSystemTreeNodeResponse fileNode = new FileSystemTreeNodeResponse
|
var fileNode = new FileSystemTreeNodeResponse
|
||||||
{
|
{
|
||||||
Name = file.Name,
|
Name = file.Name,
|
||||||
Path = file.Id.Path,
|
Path = file.Id.Path,
|
||||||
+1
-1
@@ -3,7 +3,7 @@ using FluentValidation;
|
|||||||
using Lumina.Domain.Common.Errors;
|
using Lumina.Domain.Common.Errors;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
namespace Lumina.Application.Core.FileManagement.Directories.Queries;
|
namespace Lumina.Application.Core.FileManagement.Directories.Queries.GetDirectoryTree;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Validates the needed validation rules for <see cref="GetDirectoryTreeQuery"/>.
|
/// Validates the needed validation rules for <see cref="GetDirectoryTreeQuery"/>.
|
||||||
+1
-1
@@ -5,7 +5,7 @@ using Mediator;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
namespace Lumina.Application.Core.FileManagement.Directories.Queries;
|
namespace Lumina.Application.Core.FileManagement.Directories.Queries.GetTreeDirectories;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Query for retrieving the list of directories at a path.
|
/// Query for retrieving the list of directories at a path.
|
||||||
+2
-2
@@ -11,7 +11,7 @@ using System.Threading;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
namespace Lumina.Application.Core.FileManagement.Directories.Queries;
|
namespace Lumina.Application.Core.FileManagement.Directories.Queries.GetTreeDirectories;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handler for the query to get all directories.
|
/// Handler for the query to get all directories.
|
||||||
@@ -44,7 +44,7 @@ public class GetTreeDirectoriesQueryHandler : IRequestHandler<GetTreeDirectories
|
|||||||
/// </returns>
|
/// </returns>
|
||||||
public ValueTask<ErrorOr<IEnumerable<FileSystemTreeNodeResponse>>> Handle(GetTreeDirectoriesQuery request, CancellationToken cancellationToken)
|
public ValueTask<ErrorOr<IEnumerable<FileSystemTreeNodeResponse>>> Handle(GetTreeDirectoriesQuery request, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
ErrorOr<IEnumerable<Directory>> result = _directoryService.GetSubdirectories(request.Path);
|
var result = _directoryService.GetSubdirectories(request.Path);
|
||||||
return ValueTask.FromResult(result.Match(values => ErrorOrFactory.From(result.Value.Adapt<IEnumerable<FileSystemTreeNodeResponse>>()), errors => errors));
|
return ValueTask.FromResult(result.Match(values => ErrorOrFactory.From(result.Value.Adapt<IEnumerable<FileSystemTreeNodeResponse>>()), errors => errors));
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
+1
-1
@@ -3,7 +3,7 @@ using FluentValidation;
|
|||||||
using Lumina.Domain.Common.Errors;
|
using Lumina.Domain.Common.Errors;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
namespace Lumina.Application.Core.FileManagement.Directories.Queries;
|
namespace Lumina.Application.Core.FileManagement.Directories.Queries.GetTreeDirectories;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Validates the needed validation rules for <see cref="GetTreeDirectoriesQuery"/>.
|
/// Validates the needed validation rules for <see cref="GetTreeDirectoriesQuery"/>.
|
||||||
+1
-1
@@ -5,7 +5,7 @@ using Mediator;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
namespace Lumina.Application.Core.FileManagement.Drives.Queries;
|
namespace Lumina.Application.Core.FileManagement.Drives.Queries.GetDrives;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Query for retrieving the list of drives.
|
/// Query for retrieving the list of drives.
|
||||||
+2
-2
@@ -10,7 +10,7 @@ using System.Threading;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
namespace Lumina.Application.Core.FileManagement.Drives.Queries;
|
namespace Lumina.Application.Core.FileManagement.Drives.Queries.GetDrives;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handler for the query to get all drives.
|
/// Handler for the query to get all drives.
|
||||||
@@ -43,7 +43,7 @@ public class GetDrivesQueryHandler : IRequestHandler<GetDrivesQuery, ErrorOr<IEn
|
|||||||
/// </returns>
|
/// </returns>
|
||||||
public ValueTask<ErrorOr<IEnumerable<FileSystemTreeNodeResponse>>> Handle(GetDrivesQuery request, CancellationToken cancellationToken)
|
public ValueTask<ErrorOr<IEnumerable<FileSystemTreeNodeResponse>>> Handle(GetDrivesQuery request, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
ErrorOr<IEnumerable<FileSystemItem>> result = _driveService.GetDrives();
|
var result = _driveService.GetDrives();
|
||||||
return ValueTask.FromResult(result.Match(values => ErrorOrFactory.From(values.Adapt<IEnumerable<FileSystemTreeNodeResponse>>()), errors => errors));
|
return ValueTask.FromResult(result.Match(values => ErrorOrFactory.From(values.Adapt<IEnumerable<FileSystemTreeNodeResponse>>()), errors => errors));
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
+1
-1
@@ -3,7 +3,7 @@ using Lumina.Contracts.Responses.FileManagement;
|
|||||||
using Mediator;
|
using Mediator;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
namespace Lumina.Application.Core.FileManagement.FileSystem.Queries;
|
namespace Lumina.Application.Core.FileManagement.FileSystem.Queries.GetFileSysem;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Query for retrieving the file system type.
|
/// Query for retrieving the file system type.
|
||||||
+1
-1
@@ -6,7 +6,7 @@ using System.Threading;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
namespace Lumina.Application.Core.FileManagement.FileSystem.Queries;
|
namespace Lumina.Application.Core.FileManagement.FileSystem.Queries.GetFileSysem;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handler for the query to get the file system type.
|
/// Handler for the query to get the file system type.
|
||||||
+1
-1
@@ -5,7 +5,7 @@ using Mediator;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
namespace Lumina.Application.Core.FileManagement.Files.Queries;
|
namespace Lumina.Application.Core.FileManagement.Files.Queries.GetFiles;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Query for retrieving the list of files at a path.
|
/// Query for retrieving the list of files at a path.
|
||||||
+2
-2
@@ -10,7 +10,7 @@ using System.Threading;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
namespace Lumina.Application.Core.FileManagement.Files.Queries;
|
namespace Lumina.Application.Core.FileManagement.Files.Queries.GetFiles;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handler for the query to get all files.
|
/// Handler for the query to get all files.
|
||||||
@@ -43,7 +43,7 @@ public class GetFilesQueryHandler : IRequestHandler<GetFilesQuery, ErrorOr<IEnum
|
|||||||
/// </returns>
|
/// </returns>
|
||||||
public ValueTask<ErrorOr<IEnumerable<FileResponse>>> Handle(GetFilesQuery request, CancellationToken cancellationToken)
|
public ValueTask<ErrorOr<IEnumerable<FileResponse>>> Handle(GetFilesQuery request, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
ErrorOr<IEnumerable<File>> result = _fileService.GetFiles(request.Path);
|
var result = _fileService.GetFiles(request.Path);
|
||||||
return ValueTask.FromResult(result.Match(values => ErrorOrFactory.From(result.Value.Adapt<IEnumerable<FileResponse>>()), errors => errors));
|
return ValueTask.FromResult(result.Match(values => ErrorOrFactory.From(result.Value.Adapt<IEnumerable<FileResponse>>()), errors => errors));
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
+1
-1
@@ -3,7 +3,7 @@ using FluentValidation;
|
|||||||
using Lumina.Domain.Common.Errors;
|
using Lumina.Domain.Common.Errors;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
namespace Lumina.Application.Core.FileManagement.Files.Queries;
|
namespace Lumina.Application.Core.FileManagement.Files.Queries.GetFiles;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Validates the needed validation rules for <see cref="GetFilesQuery"/>.
|
/// Validates the needed validation rules for <see cref="GetFilesQuery"/>.
|
||||||
+1
-1
@@ -5,7 +5,7 @@ using Mediator;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
namespace Lumina.Application.Core.FileManagement.Files.Queries;
|
namespace Lumina.Application.Core.FileManagement.Files.Queries.GetTreeFiles;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Query for retrieving the list of files at a path.
|
/// Query for retrieving the list of files at a path.
|
||||||
+2
-2
@@ -10,7 +10,7 @@ using System.Threading;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
namespace Lumina.Application.Core.FileManagement.Files.Queries;
|
namespace Lumina.Application.Core.FileManagement.Files.Queries.GetTreeFiles;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handler for the query to get all files.
|
/// Handler for the query to get all files.
|
||||||
@@ -43,7 +43,7 @@ public class GetTreeFilesQueryHandler : IRequestHandler<GetTreeFilesQuery, Error
|
|||||||
/// </returns>
|
/// </returns>
|
||||||
public ValueTask<ErrorOr<IEnumerable<FileSystemTreeNodeResponse>>> Handle(GetTreeFilesQuery request, CancellationToken cancellationToken)
|
public ValueTask<ErrorOr<IEnumerable<FileSystemTreeNodeResponse>>> Handle(GetTreeFilesQuery request, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
ErrorOr<IEnumerable<File>> result = _fileService.GetFiles(request.Path);
|
var result = _fileService.GetFiles(request.Path);
|
||||||
return ValueTask.FromResult(result.Match(values => ErrorOrFactory.From(result.Value.Adapt<IEnumerable<FileSystemTreeNodeResponse>>()), errors => errors));
|
return ValueTask.FromResult(result.Match(values => ErrorOrFactory.From(result.Value.Adapt<IEnumerable<FileSystemTreeNodeResponse>>()), errors => errors));
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
+1
-1
@@ -3,7 +3,7 @@ using FluentValidation;
|
|||||||
using Lumina.Domain.Common.Errors;
|
using Lumina.Domain.Common.Errors;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
namespace Lumina.Application.Core.FileManagement.Files.Queries;
|
namespace Lumina.Application.Core.FileManagement.Files.Queries.GetTreeFiles;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Validates the needed validation rules for <see cref="GetTreeFilesQuery"/>.
|
/// Validates the needed validation rules for <see cref="GetTreeFilesQuery"/>.
|
||||||
+1
-1
@@ -4,7 +4,7 @@ using Lumina.Contracts.Responses.FileManagement;
|
|||||||
using Mediator;
|
using Mediator;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
namespace Lumina.Application.Core.FileManagement.Paths.Commands;
|
namespace Lumina.Application.Core.FileManagement.Paths.Commands.CombinePath;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Command for combining two file system path.
|
/// Command for combining two file system path.
|
||||||
+3
-2
@@ -1,5 +1,6 @@
|
|||||||
#region ========================================================================= USING =====================================================================================
|
#region ========================================================================= USING =====================================================================================
|
||||||
using ErrorOr;
|
using ErrorOr;
|
||||||
|
using Lumina.Application.Core.FileManagement.Paths.Commands.SplitPath;
|
||||||
using Lumina.Contracts.Responses.FileManagement;
|
using Lumina.Contracts.Responses.FileManagement;
|
||||||
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Services;
|
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Services;
|
||||||
using Mapster;
|
using Mapster;
|
||||||
@@ -8,7 +9,7 @@ using System.Threading;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
namespace Lumina.Application.Core.FileManagement.Paths.Commands;
|
namespace Lumina.Application.Core.FileManagement.Paths.Commands.CombinePath;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handler for the command to split a file system path.
|
/// Handler for the command to split a file system path.
|
||||||
@@ -41,7 +42,7 @@ public class CombinePathCommandHandler : IRequestHandler<CombinePathCommand, Err
|
|||||||
/// </returns>
|
/// </returns>
|
||||||
public ValueTask<ErrorOr<PathSegmentResponse>> Handle(CombinePathCommand request, CancellationToken cancellationToken)
|
public ValueTask<ErrorOr<PathSegmentResponse>> Handle(CombinePathCommand request, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
ErrorOr<string> result = _pathService.CombinePath(request.OriginalPath, request.NewPath);
|
var result = _pathService.CombinePath(request.OriginalPath, request.NewPath);
|
||||||
return ValueTask.FromResult(result.Match(values => ErrorOrFactory.From(new PathSegmentResponse(result.Value)), errors => errors));
|
return ValueTask.FromResult(result.Match(values => ErrorOrFactory.From(new PathSegmentResponse(result.Value)), errors => errors));
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
+1
-1
@@ -3,7 +3,7 @@ using FluentValidation;
|
|||||||
using Lumina.Domain.Common.Errors;
|
using Lumina.Domain.Common.Errors;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
namespace Lumina.Application.Core.FileManagement.Paths.Commands;
|
namespace Lumina.Application.Core.FileManagement.Paths.Commands.CombinePath;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Validates the needed validation rules for <see cref="CombinePathCommand"/>.
|
/// Validates the needed validation rules for <see cref="CombinePathCommand"/>.
|
||||||
+1
-1
@@ -5,7 +5,7 @@ using Mediator;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
namespace Lumina.Application.Core.FileManagement.Paths.Commands;
|
namespace Lumina.Application.Core.FileManagement.Paths.Commands.SplitPath;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Command for splitting a file system path.
|
/// Command for splitting a file system path.
|
||||||
+2
-2
@@ -10,7 +10,7 @@ using System.Threading;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
namespace Lumina.Application.Core.FileManagement.Paths.Commands;
|
namespace Lumina.Application.Core.FileManagement.Paths.Commands.SplitPath;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handler for the command to split a file system path.
|
/// Handler for the command to split a file system path.
|
||||||
@@ -43,7 +43,7 @@ public class SplitPathCommandHandler : IRequestHandler<SplitPathCommand, ErrorOr
|
|||||||
/// </returns>
|
/// </returns>
|
||||||
public ValueTask<ErrorOr<IEnumerable<PathSegmentResponse>>> Handle(SplitPathCommand request, CancellationToken cancellationToken)
|
public ValueTask<ErrorOr<IEnumerable<PathSegmentResponse>>> Handle(SplitPathCommand request, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
ErrorOr<IEnumerable<PathSegment>> result = _pathService.ParsePath(request.Path);
|
var result = _pathService.ParsePath(request.Path);
|
||||||
return ValueTask.FromResult(result.Match(values => ErrorOrFactory.From(result.Value.Adapt<IEnumerable<PathSegmentResponse>>()), errors => errors));
|
return ValueTask.FromResult(result.Match(values => ErrorOrFactory.From(result.Value.Adapt<IEnumerable<PathSegmentResponse>>()), errors => errors));
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
+1
-1
@@ -3,7 +3,7 @@ using FluentValidation;
|
|||||||
using Lumina.Domain.Common.Errors;
|
using Lumina.Domain.Common.Errors;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
namespace Lumina.Application.Core.FileManagement.Paths.Commands;
|
namespace Lumina.Application.Core.FileManagement.Paths.Commands.SplitPath;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Validates the needed validation rules for <see cref="SplitPathCommand"/>.
|
/// Validates the needed validation rules for <see cref="SplitPathCommand"/>.
|
||||||
+2
@@ -3,6 +3,8 @@ using Lumina.Contracts.Responses.FileManagement;
|
|||||||
using Mediator;
|
using Mediator;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
namespace Lumina.Application.Core.FileManagement.Paths.Queries.CheckPathExists;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Query for retrieving the existence of a file system path.
|
/// Query for retrieving the existence of a file system path.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
+1
-1
@@ -6,7 +6,7 @@ using System.Threading;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
namespace Lumina.Application.Core.FileManagement.Paths.Queries;
|
namespace Lumina.Application.Core.FileManagement.Paths.Queries.CheckPathExists;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handler for the query to check the existence a file system path.
|
/// Handler for the query to check the existence a file system path.
|
||||||
+1
-1
@@ -3,7 +3,7 @@ using FluentValidation;
|
|||||||
using Lumina.Domain.Common.Errors;
|
using Lumina.Domain.Common.Errors;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
namespace Lumina.Application.Core.FileManagement.Paths.Queries;
|
namespace Lumina.Application.Core.FileManagement.Paths.Queries.CheckPathExists;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Validates the needed validation rules for <see cref="CheckPathExistsQuery"/>.
|
/// Validates the needed validation rules for <see cref="CheckPathExistsQuery"/>.
|
||||||
+1
-1
@@ -5,7 +5,7 @@ using Mediator;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
namespace Lumina.Application.Core.FileManagement.Paths.Queries;
|
namespace Lumina.Application.Core.FileManagement.Paths.Queries.GetPathParent;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Query for retrieving the parent of a file system path.
|
/// Query for retrieving the parent of a file system path.
|
||||||
+2
-2
@@ -10,7 +10,7 @@ using System.Threading;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
namespace Lumina.Application.Core.FileManagement.Paths.Queries;
|
namespace Lumina.Application.Core.FileManagement.Paths.Queries.GetPathParent;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handler for the query to get the parent of a file system path.
|
/// Handler for the query to get the parent of a file system path.
|
||||||
@@ -43,7 +43,7 @@ public class GetPathParentQueryHandler : IRequestHandler<GetPathParentQuery, Err
|
|||||||
/// </returns>
|
/// </returns>
|
||||||
public ValueTask<ErrorOr<IEnumerable<PathSegmentResponse>>> Handle(GetPathParentQuery request, CancellationToken cancellationToken)
|
public ValueTask<ErrorOr<IEnumerable<PathSegmentResponse>>> Handle(GetPathParentQuery request, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
ErrorOr<IEnumerable<PathSegment>> result = _pathService.GoUpOneLevel(request.Path);
|
var result = _pathService.GoUpOneLevel(request.Path);
|
||||||
return ValueTask.FromResult(result.Match(values => ErrorOrFactory.From(result.Value.Adapt<IEnumerable<PathSegmentResponse>>()), errors => errors));
|
return ValueTask.FromResult(result.Match(values => ErrorOrFactory.From(result.Value.Adapt<IEnumerable<PathSegmentResponse>>()), errors => errors));
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
+1
-1
@@ -3,7 +3,7 @@ using FluentValidation;
|
|||||||
using Lumina.Domain.Common.Errors;
|
using Lumina.Domain.Common.Errors;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
namespace Lumina.Application.Core.FileManagement.Paths.Queries;
|
namespace Lumina.Application.Core.FileManagement.Paths.Queries.GetPathParent;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Validates the needed validation rules for <see cref="GetPathParentQuery"/>.
|
/// Validates the needed validation rules for <see cref="GetPathParentQuery"/>.
|
||||||
+1
-1
@@ -4,7 +4,7 @@ using Lumina.Contracts.Responses.FileManagement;
|
|||||||
using Mediator;
|
using Mediator;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
namespace Lumina.Application.Core.FileManagement.Paths.Queries;
|
namespace Lumina.Application.Core.FileManagement.Paths.Queries.GetPathRoot;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Query for retrieving the root of a path.
|
/// Query for retrieving the root of a path.
|
||||||
+2
-2
@@ -9,7 +9,7 @@ using System.Threading;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
namespace Lumina.Application.Core.FileManagement.Paths.Queries;
|
namespace Lumina.Application.Core.FileManagement.Paths.Queries.GetPathRoot;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handler for the query to get the root of a file system path.
|
/// Handler for the query to get the root of a file system path.
|
||||||
@@ -40,7 +40,7 @@ public class GetPathRootQueryHandler : IRequestHandler<GetPathRootQuery, ErrorOr
|
|||||||
/// <returns>The root of the specified path.</returns>
|
/// <returns>The root of the specified path.</returns>
|
||||||
public ValueTask<ErrorOr<PathSegmentResponse>> Handle(GetPathRootQuery request, CancellationToken cancellationToken)
|
public ValueTask<ErrorOr<PathSegmentResponse>> Handle(GetPathRootQuery request, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
ErrorOr<PathSegment> result = _pathService.GetPathRoot(request.Path);
|
var result = _pathService.GetPathRoot(request.Path);
|
||||||
return ValueTask.FromResult(result.Match(values => ErrorOrFactory.From(result.Value.Adapt<PathSegmentResponse>()), errors => errors));
|
return ValueTask.FromResult(result.Match(values => ErrorOrFactory.From(result.Value.Adapt<PathSegmentResponse>()), errors => errors));
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
+1
-1
@@ -3,7 +3,7 @@ using FluentValidation;
|
|||||||
using Lumina.Domain.Common.Errors;
|
using Lumina.Domain.Common.Errors;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
namespace Lumina.Application.Core.FileManagement.Paths.Queries;
|
namespace Lumina.Application.Core.FileManagement.Paths.Queries.GetPathRoot;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Validates the needed validation rules for <see cref="GetPathRootQuery"/>.
|
/// Validates the needed validation rules for <see cref="GetPathRootQuery"/>.
|
||||||
+1
-1
@@ -3,7 +3,7 @@ using Lumina.Contracts.Responses.FileManagement;
|
|||||||
using Mediator;
|
using Mediator;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
namespace Lumina.Application.Core.FileManagement.Paths.Queries;
|
namespace Lumina.Application.Core.FileManagement.Paths.Queries.GetPathSeparator;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Query for retrieving the file system path separator.
|
/// Query for retrieving the file system path separator.
|
||||||
+1
-1
@@ -6,7 +6,7 @@ using System.Threading;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
namespace Lumina.Application.Core.FileManagement.Paths.Queries;
|
namespace Lumina.Application.Core.FileManagement.Paths.Queries.GetPathSeparator;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handler for the query to get the path separator character of a file system path.
|
/// Handler for the query to get the path separator character of a file system path.
|
||||||
+1
-1
@@ -3,7 +3,7 @@ using Lumina.Contracts.Responses.FileManagement;
|
|||||||
using Mediator;
|
using Mediator;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
namespace Lumina.Application.Core.FileManagement.Paths.Queries;
|
namespace Lumina.Application.Core.FileManagement.Paths.Queries.ValidatePath;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Query for validating a path.
|
/// Query for validating a path.
|
||||||
+1
-1
@@ -6,7 +6,7 @@ using System.Threading;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
namespace Lumina.Application.Core.FileManagement.Paths.Queries;
|
namespace Lumina.Application.Core.FileManagement.Paths.Queries.ValidatePath;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handler for the query to validate a file system path.
|
/// Handler for the query to validate a file system path.
|
||||||
+1
-1
@@ -3,7 +3,7 @@ using FluentValidation;
|
|||||||
using Lumina.Domain.Common.Errors;
|
using Lumina.Domain.Common.Errors;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
namespace Lumina.Application.Core.FileManagement.Paths.Queries;
|
namespace Lumina.Application.Core.FileManagement.Paths.Queries.ValidatePath;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Validates the needed validation rules for <see cref="ValidatePathQuery"/>.
|
/// Validates the needed validation rules for <see cref="ValidatePathQuery"/>.
|
||||||
+1
-1
@@ -9,7 +9,7 @@ using Mediator;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
namespace Lumina.Application.Core.WrittenContentLibrary.BooksLibrary.Books.Commands;
|
namespace Lumina.Application.Core.WrittenContentLibrary.BooksLibrary.Books.Commands.AddBook;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Command for adding a book.
|
/// Command for adding a book.
|
||||||
+14
-14
@@ -19,7 +19,7 @@ using System.Threading;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
namespace Lumina.Application.Core.WrittenContentLibrary.BooksLibrary.Books.Commands;
|
namespace Lumina.Application.Core.WrittenContentLibrary.BooksLibrary.Books.Commands.AddBook;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handler for the command to add a book.
|
/// Handler for the command to add a book.
|
||||||
@@ -57,7 +57,7 @@ public class AddBookCommandHandler : IRequestHandler<AddBookCommand, ErrorOr<Boo
|
|||||||
{
|
{
|
||||||
// TODO: update Api.Book.md documentation when the functionality is fully implemented
|
// TODO: update Api.Book.md documentation when the functionality is fully implemented
|
||||||
List<MediaContributorId> contributorIds = [];
|
List<MediaContributorId> contributorIds = [];
|
||||||
foreach(var mediaContributor in request.Contributors)
|
foreach (var mediaContributor in request.Contributors)
|
||||||
{
|
{
|
||||||
// TODO: add logic to search the media contributors repository for existing contributors, based on the provided names
|
// TODO: add logic to search the media contributors repository for existing contributors, based on the provided names
|
||||||
}
|
}
|
||||||
@@ -76,26 +76,26 @@ public class AddBookCommandHandler : IRequestHandler<AddBookCommand, ErrorOr<Boo
|
|||||||
var errors = domainRatingsResult.Where(ratingResult => ratingResult.IsError).SelectMany(ratingResult => ratingResult.Errors).ToList();
|
var errors = domainRatingsResult.Where(ratingResult => ratingResult.IsError).SelectMany(ratingResult => ratingResult.Errors).ToList();
|
||||||
if (errors.Count != 0) // if there are errors, return them
|
if (errors.Count != 0) // if there are errors, return them
|
||||||
return errors;
|
return errors;
|
||||||
|
|
||||||
List<BookRating> domainRatings = domainRatingsResult.Select(rating => rating.Value).ToList();
|
var domainRatings = domainRatingsResult.Select(rating => rating.Value).ToList();
|
||||||
|
|
||||||
var domainGenresResult = request.Metadata.Genres!.ConvertAll(genre => Genre.Create(genre.Name!));
|
var domainGenresResult = request.Metadata.Genres!.ConvertAll(genre => Genre.Create(genre.Name!));
|
||||||
errors = domainGenresResult.Where(genreResult => genreResult.IsError).SelectMany(genreResult => genreResult.Errors).ToList();
|
errors = domainGenresResult.Where(genreResult => genreResult.IsError).SelectMany(genreResult => genreResult.Errors).ToList();
|
||||||
if (errors.Count != 0)
|
if (errors.Count != 0)
|
||||||
return errors;
|
return errors;
|
||||||
List<Genre> domainGenres = domainGenresResult.Select(genre => genre.Value).ToList();
|
var domainGenres = domainGenresResult.Select(genre => genre.Value).ToList();
|
||||||
|
|
||||||
var domainTagsResult = request.Metadata.Tags!.ConvertAll(tag => Tag.Create(tag.Name!));
|
var domainTagsResult = request.Metadata.Tags!.ConvertAll(tag => Tag.Create(tag.Name!));
|
||||||
errors = domainTagsResult.Where(tagResult => tagResult.IsError).SelectMany(tagResult => tagResult.Errors).ToList();
|
errors = domainTagsResult.Where(tagResult => tagResult.IsError).SelectMany(tagResult => tagResult.Errors).ToList();
|
||||||
if (errors.Count != 0)
|
if (errors.Count != 0)
|
||||||
return errors;
|
return errors;
|
||||||
List<Tag> domainTags = domainTagsResult.Select(tag => tag.Value).ToList();
|
var domainTags = domainTagsResult.Select(tag => tag.Value).ToList();
|
||||||
|
|
||||||
var domainIsbnsResult = request.ISBNs.ConvertAll(isbn => Isbn.Create(isbn.Value!, (IsbnFormat)(int)isbn.Format!));
|
var domainIsbnsResult = request.ISBNs.ConvertAll(isbn => Isbn.Create(isbn.Value!, (IsbnFormat)(int)isbn.Format!));
|
||||||
errors = domainIsbnsResult.Where(isbnResult => isbnResult.IsError).SelectMany(isbnResult => isbnResult.Errors).ToList();
|
errors = domainIsbnsResult.Where(isbnResult => isbnResult.IsError).SelectMany(isbnResult => isbnResult.Errors).ToList();
|
||||||
if (errors.Count != 0)
|
if (errors.Count != 0)
|
||||||
return errors;
|
return errors;
|
||||||
List<Isbn> domainIsbns = domainIsbnsResult.Select(isbn => isbn.Value).ToList();
|
var domainIsbns = domainIsbnsResult.Select(isbn => isbn.Value).ToList();
|
||||||
|
|
||||||
var releaseInfoResult = ReleaseInfo.Create(
|
var releaseInfoResult = ReleaseInfo.Create(
|
||||||
Optional<DateOnly>.FromNullable(request.Metadata.ReleaseInfo!.OriginalReleaseDate),
|
Optional<DateOnly>.FromNullable(request.Metadata.ReleaseInfo!.OriginalReleaseDate),
|
||||||
@@ -107,13 +107,13 @@ public class AddBookCommandHandler : IRequestHandler<AddBookCommand, ErrorOr<Boo
|
|||||||
);
|
);
|
||||||
if (releaseInfoResult.IsError)
|
if (releaseInfoResult.IsError)
|
||||||
return releaseInfoResult.Errors;
|
return releaseInfoResult.Errors;
|
||||||
ReleaseInfo releaseInfo = releaseInfoResult.Value;
|
var releaseInfo = releaseInfoResult.Value;
|
||||||
LanguageInfo? languageInfo = null;
|
LanguageInfo? languageInfo = null;
|
||||||
if (request.Metadata.Language is not null)
|
if (request.Metadata.Language is not null)
|
||||||
{
|
{
|
||||||
var languageInfoResult = LanguageInfo.Create(
|
var languageInfoResult = LanguageInfo.Create(
|
||||||
request.Metadata.Language.LanguageCode!,
|
request.Metadata.Language.LanguageCode!,
|
||||||
request.Metadata.Language.LanguageName!,
|
request.Metadata.Language.LanguageName!,
|
||||||
Optional<string>.FromNullable(request.Metadata.Language.NativeName));
|
Optional<string>.FromNullable(request.Metadata.Language.NativeName));
|
||||||
if (languageInfoResult.IsError)
|
if (languageInfoResult.IsError)
|
||||||
return languageInfoResult.Errors;
|
return languageInfoResult.Errors;
|
||||||
@@ -123,7 +123,7 @@ public class AddBookCommandHandler : IRequestHandler<AddBookCommand, ErrorOr<Boo
|
|||||||
if (request.Metadata.OriginalLanguage is not null)
|
if (request.Metadata.OriginalLanguage is not null)
|
||||||
{
|
{
|
||||||
var originalLanguageInfoResult = LanguageInfo.Create(
|
var originalLanguageInfoResult = LanguageInfo.Create(
|
||||||
request.Metadata.OriginalLanguage.LanguageCode!,
|
request.Metadata.OriginalLanguage.LanguageCode!,
|
||||||
request.Metadata.OriginalLanguage.LanguageName!,
|
request.Metadata.OriginalLanguage.LanguageName!,
|
||||||
Optional<string>.FromNullable(request.Metadata.OriginalLanguage.NativeName));
|
Optional<string>.FromNullable(request.Metadata.OriginalLanguage.NativeName));
|
||||||
if (originalLanguageInfoResult.IsError)
|
if (originalLanguageInfoResult.IsError)
|
||||||
@@ -140,7 +140,7 @@ public class AddBookCommandHandler : IRequestHandler<AddBookCommand, ErrorOr<Boo
|
|||||||
Optional<LanguageInfo>.FromNullable(languageInfo),
|
Optional<LanguageInfo>.FromNullable(languageInfo),
|
||||||
Optional<LanguageInfo>.FromNullable(originalLanguageInfo),
|
Optional<LanguageInfo>.FromNullable(originalLanguageInfo),
|
||||||
Optional<string>.FromNullable(request.Metadata.Publisher),
|
Optional<string>.FromNullable(request.Metadata.Publisher),
|
||||||
Optional<int>.FromNullable(request.Metadata.PageCount)
|
Optional<int>.FromNullable(request.Metadata.PageCount)
|
||||||
);
|
);
|
||||||
if (metadataResult.IsError)
|
if (metadataResult.IsError)
|
||||||
return metadataResult.Errors;
|
return metadataResult.Errors;
|
||||||
+6
-6
@@ -4,7 +4,7 @@ using Lumina.Contracts.Enums.BookLibrary;
|
|||||||
using Lumina.Domain.Common.Errors;
|
using Lumina.Domain.Common.Errors;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
namespace Lumina.Application.Core.WrittenContentLibrary.BooksLibrary.Books.Commands;
|
namespace Lumina.Application.Core.WrittenContentLibrary.BooksLibrary.Books.Commands.AddBook;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Validates the needed validation rules for <see cref="AddBookCommand"/>.
|
/// Validates the needed validation rules for <see cref="AddBookCommand"/>.
|
||||||
@@ -64,14 +64,14 @@ public class AddBookCommandValidator : AbstractValidator<AddBookCommand>
|
|||||||
metadata.RuleFor(m => m.Genres)
|
metadata.RuleFor(m => m.Genres)
|
||||||
.NotNull().WithMessage(Errors.Metadata.GenresListCannotBeNull.Code);
|
.NotNull().WithMessage(Errors.Metadata.GenresListCannotBeNull.Code);
|
||||||
metadata.RuleForEach(m => m.Genres)
|
metadata.RuleForEach(m => m.Genres)
|
||||||
.ChildRules(g =>
|
.ChildRules(g =>
|
||||||
g.RuleFor(genre => genre.Name)
|
g.RuleFor(genre => genre.Name)
|
||||||
.NotEmpty().WithMessage(Errors.Metadata.GenreNameCannotBeEmpty.Code)
|
.NotEmpty().WithMessage(Errors.Metadata.GenreNameCannotBeEmpty.Code)
|
||||||
.MaximumLength(50).WithMessage(Errors.Metadata.GenreNameMustBeMaximum50CharactersLong.Code));
|
.MaximumLength(50).WithMessage(Errors.Metadata.GenreNameMustBeMaximum50CharactersLong.Code));
|
||||||
metadata.RuleFor(m => m.Tags)
|
metadata.RuleFor(m => m.Tags)
|
||||||
.NotNull().WithMessage(Errors.Metadata.TagsListCannotBeNull.Code);
|
.NotNull().WithMessage(Errors.Metadata.TagsListCannotBeNull.Code);
|
||||||
metadata.RuleForEach(m => m.Tags)
|
metadata.RuleForEach(m => m.Tags)
|
||||||
.ChildRules(t =>
|
.ChildRules(t =>
|
||||||
t.RuleFor(tag => tag.Name)
|
t.RuleFor(tag => tag.Name)
|
||||||
.NotEmpty().WithMessage(Errors.Metadata.TagNameCannotBeEmpty.Code)
|
.NotEmpty().WithMessage(Errors.Metadata.TagNameCannotBeEmpty.Code)
|
||||||
.MaximumLength(50).WithMessage(Errors.Metadata.TagNameMustBeMaximum50CharactersLong.Code));
|
.MaximumLength(50).WithMessage(Errors.Metadata.TagNameMustBeMaximum50CharactersLong.Code));
|
||||||
@@ -117,7 +117,7 @@ public class AddBookCommandValidator : AbstractValidator<AddBookCommand>
|
|||||||
.GreaterThan(0).When(x => x.VolumeNumber.HasValue)
|
.GreaterThan(0).When(x => x.VolumeNumber.HasValue)
|
||||||
.WithMessage(Errors.WrittenContent.VolumeNumberMustBeGreaterThanZero.Code);
|
.WithMessage(Errors.WrittenContent.VolumeNumberMustBeGreaterThanZero.Code);
|
||||||
RuleFor(x => x.Series)
|
RuleFor(x => x.Series)
|
||||||
.ChildRules(s =>
|
.ChildRules(s =>
|
||||||
s.RuleFor(series => series!.Title)
|
s.RuleFor(series => series!.Title)
|
||||||
.NotEmpty().WithMessage(Errors.Metadata.TitleCannotBeEmpty.Code)
|
.NotEmpty().WithMessage(Errors.Metadata.TitleCannotBeEmpty.Code)
|
||||||
.MaximumLength(255)).WithMessage(Errors.Metadata.TitleMustBeMaximum255CharactersLong.Code)
|
.MaximumLength(255)).WithMessage(Errors.Metadata.TitleMustBeMaximum255CharactersLong.Code)
|
||||||
@@ -127,7 +127,7 @@ public class AddBookCommandValidator : AbstractValidator<AddBookCommand>
|
|||||||
.WithMessage(Errors.WrittenContent.AsinMustBe10CharactersLong.Code);
|
.WithMessage(Errors.WrittenContent.AsinMustBe10CharactersLong.Code);
|
||||||
RuleFor(x => x.GoodreadsId)
|
RuleFor(x => x.GoodreadsId)
|
||||||
.Matches(@"^\d+$").When(x => x.GoodreadsId is not null)
|
.Matches(@"^\d+$").When(x => x.GoodreadsId is not null)
|
||||||
.WithMessage(Errors.WrittenContent.GoodreadsIdMustBeNumeric.Code);
|
.WithMessage(Errors.WrittenContent.GoodreadsIdMustBeNumeric.Code);
|
||||||
RuleFor(x => x.LCCN)
|
RuleFor(x => x.LCCN)
|
||||||
.Matches(@"^[a-z]{0,3}\d{8,10}$").WithMessage(Errors.WrittenContent.InvalidLccnFormat.Code)
|
.Matches(@"^[a-z]{0,3}\d{8,10}$").WithMessage(Errors.WrittenContent.InvalidLccnFormat.Code)
|
||||||
.When(x => x.LCCN is not null);
|
.When(x => x.LCCN is not null);
|
||||||
@@ -185,7 +185,7 @@ public class AddBookCommandValidator : AbstractValidator<AddBookCommand>
|
|||||||
.WithMessage(Errors.MediaContributor.ContributorLegalNameMustBeMaximum100CharactersLong.Code);
|
.WithMessage(Errors.MediaContributor.ContributorLegalNameMustBeMaximum100CharactersLong.Code);
|
||||||
});
|
});
|
||||||
contributor.RuleFor(c => c.Role)
|
contributor.RuleFor(c => c.Role)
|
||||||
.NotNull().WithMessage(Errors.MediaContributor.ContributorRoleCannotBeNull.Code)
|
.NotNull().WithMessage(Errors.MediaContributor.ContributorRoleCannotBeNull.Code)
|
||||||
.ChildRules(role =>
|
.ChildRules(role =>
|
||||||
{
|
{
|
||||||
role.RuleFor(r => r!.Name)
|
role.RuleFor(r => r!.Name)
|
||||||
+1
-1
@@ -5,7 +5,7 @@ using Mediator;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
namespace Lumina.Application.Core.WrittenContentLibrary.BooksLibrary.Books.Queries;
|
namespace Lumina.Application.Core.WrittenContentLibrary.BooksLibrary.Books.Queries.GetBooks;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Query for getting all books.
|
/// Query for getting all books.
|
||||||
+1
-1
@@ -10,7 +10,7 @@ using System.Threading;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
namespace Lumina.Application.Core.WrittenContentLibrary.BooksLibrary.Books.Queries;
|
namespace Lumina.Application.Core.WrittenContentLibrary.BooksLibrary.Books.Queries.GetBooks;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handler for the query to get all books.
|
/// Handler for the query to get all books.
|
||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
#region ========================================================================= USING =====================================================================================
|
#region ========================================================================= USING =====================================================================================
|
||||||
using Lumina.Application.Core.WrittenContentLibrary.BooksLibrary.Books.Commands;
|
using Lumina.Application.Core.WrittenContentLibrary.BooksLibrary.Books.Commands.AddBook;
|
||||||
using Lumina.Contracts.Requests.WrittenContentLibrary.BookLibrary;
|
using Lumina.Contracts.Requests.WrittenContentLibrary.BookLibrary;
|
||||||
using Mapster;
|
using Mapster;
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
+3
-1
@@ -1,6 +1,8 @@
|
|||||||
#region ========================================================================= USING =====================================================================================
|
#region ========================================================================= USING =====================================================================================
|
||||||
using ErrorOr;
|
using ErrorOr;
|
||||||
using Lumina.Application.Core.FileManagement.Directories.Queries;
|
using Lumina.Application.Core.FileManagement.Directories.Queries.GetDirectories;
|
||||||
|
using Lumina.Application.Core.FileManagement.Directories.Queries.GetDirectoryTree;
|
||||||
|
using Lumina.Application.Core.FileManagement.Directories.Queries.GetTreeDirectories;
|
||||||
using Lumina.Contracts.Responses.FileManagement;
|
using Lumina.Contracts.Responses.FileManagement;
|
||||||
using Lumina.Presentation.Api.Common.ModelBinders;
|
using Lumina.Presentation.Api.Common.ModelBinders;
|
||||||
using Lumina.Presentation.Api.Core.Controllers.Common;
|
using Lumina.Presentation.Api.Core.Controllers.Common;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#region ========================================================================= USING =====================================================================================
|
#region ========================================================================= USING =====================================================================================
|
||||||
using ErrorOr;
|
using ErrorOr;
|
||||||
using Lumina.Application.Core.FileManagement.Drives.Queries;
|
using Lumina.Application.Core.FileManagement.Drives.Queries.GetDrives;
|
||||||
using Lumina.Contracts.Responses.FileManagement;
|
using Lumina.Contracts.Responses.FileManagement;
|
||||||
using Lumina.Presentation.Api.Core.Controllers.Common;
|
using Lumina.Presentation.Api.Core.Controllers.Common;
|
||||||
using Mediator;
|
using Mediator;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#region ========================================================================= USING =====================================================================================
|
#region ========================================================================= USING =====================================================================================
|
||||||
using Lumina.Application.Core.FileManagement.FileSystem.Queries;
|
using Lumina.Application.Core.FileManagement.FileSystem.Queries.GetFileSysem;
|
||||||
using Lumina.Presentation.Api.Core.Controllers.Common;
|
using Lumina.Presentation.Api.Core.Controllers.Common;
|
||||||
using Mediator;
|
using Mediator;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#region ========================================================================= USING =====================================================================================
|
#region ========================================================================= USING =====================================================================================
|
||||||
using ErrorOr;
|
using ErrorOr;
|
||||||
using Lumina.Application.Core.FileManagement.Files.Queries;
|
using Lumina.Application.Core.FileManagement.Files.Queries.GetFiles;
|
||||||
|
using Lumina.Application.Core.FileManagement.Files.Queries.GetTreeFiles;
|
||||||
using Lumina.Contracts.Responses.FileManagement;
|
using Lumina.Contracts.Responses.FileManagement;
|
||||||
using Lumina.Presentation.Api.Common.ModelBinders;
|
using Lumina.Presentation.Api.Common.ModelBinders;
|
||||||
using Lumina.Presentation.Api.Core.Controllers.Common;
|
using Lumina.Presentation.Api.Core.Controllers.Common;
|
||||||
|
|||||||
@@ -1,11 +1,15 @@
|
|||||||
#region ========================================================================= USING =====================================================================================
|
#region ========================================================================= USING =====================================================================================
|
||||||
using ErrorOr;
|
using ErrorOr;
|
||||||
using Lumina.Application.Core.FileManagement.Paths.Commands;
|
using Lumina.Application.Core.FileManagement.Paths.Commands.CombinePath;
|
||||||
using Lumina.Application.Core.FileManagement.Paths.Queries;
|
using Lumina.Application.Core.FileManagement.Paths.Commands.SplitPath;
|
||||||
|
using Lumina.Application.Core.FileManagement.Paths.Queries.CheckPathExists;
|
||||||
|
using Lumina.Application.Core.FileManagement.Paths.Queries.GetPathParent;
|
||||||
|
using Lumina.Application.Core.FileManagement.Paths.Queries.GetPathRoot;
|
||||||
|
using Lumina.Application.Core.FileManagement.Paths.Queries.GetPathSeparator;
|
||||||
|
using Lumina.Application.Core.FileManagement.Paths.Queries.ValidatePath;
|
||||||
using Lumina.Contracts.Responses.FileManagement;
|
using Lumina.Contracts.Responses.FileManagement;
|
||||||
using Lumina.Presentation.Api.Common.ModelBinders;
|
using Lumina.Presentation.Api.Common.ModelBinders;
|
||||||
using Lumina.Presentation.Api.Core.Controllers.Common;
|
using Lumina.Presentation.Api.Core.Controllers.Common;
|
||||||
using MapsterMapper;
|
|
||||||
using Mediator;
|
using Mediator;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|||||||
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
#region ========================================================================= USING =====================================================================================
|
#region ========================================================================= USING =====================================================================================
|
||||||
using Lumina.Application.Core.WrittenContentLibrary.BooksLibrary.Books.Commands;
|
using Lumina.Application.Core.WrittenContentLibrary.BooksLibrary.Books.Commands.AddBook;
|
||||||
using Lumina.Application.Core.WrittenContentLibrary.BooksLibrary.Books.Queries;
|
using Lumina.Application.Core.WrittenContentLibrary.BooksLibrary.Books.Queries.GetBooks;
|
||||||
using Lumina.Contracts.Requests.WrittenContentLibrary.BookLibrary;
|
using Lumina.Contracts.Requests.WrittenContentLibrary.BookLibrary;
|
||||||
using Lumina.Presentation.Api.Core.Controllers.Common;
|
using Lumina.Presentation.Api.Core.Controllers.Common;
|
||||||
using MapsterMapper;
|
using MapsterMapper;
|
||||||
|
|||||||
+1
-1
@@ -5,7 +5,7 @@ using ErrorOr;
|
|||||||
using FluentAssertions;
|
using FluentAssertions;
|
||||||
using Lumina.Application.Common.DataAccess.Repositories.Books;
|
using Lumina.Application.Common.DataAccess.Repositories.Books;
|
||||||
using Lumina.Application.Common.DataAccess.UoW;
|
using Lumina.Application.Common.DataAccess.UoW;
|
||||||
using Lumina.Application.Core.WrittenContentLibrary.BooksLibrary.Books.Commands;
|
using Lumina.Application.Core.WrittenContentLibrary.BooksLibrary.Books.Commands.AddBook;
|
||||||
using Lumina.Application.UnitTests.Common.Setup;
|
using Lumina.Application.UnitTests.Common.Setup;
|
||||||
using Lumina.Application.UnitTests.Core.WrittenContentLibrary.BooksLibrary.Books.Commands.Fixtures;
|
using Lumina.Application.UnitTests.Core.WrittenContentLibrary.BooksLibrary.Books.Commands.Fixtures;
|
||||||
using Lumina.Contracts.Enums.BookLibrary;
|
using Lumina.Contracts.Enums.BookLibrary;
|
||||||
|
|||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
#region ========================================================================= USING =====================================================================================
|
#region ========================================================================= USING =====================================================================================
|
||||||
using Bogus;
|
using Bogus;
|
||||||
using FluentValidation.TestHelper;
|
using FluentValidation.TestHelper;
|
||||||
using Lumina.Application.Core.WrittenContentLibrary.BooksLibrary.Books.Commands;
|
using Lumina.Application.Core.WrittenContentLibrary.BooksLibrary.Books.Commands.AddBook;
|
||||||
using Lumina.Application.UnitTests.Core.WrittenContentLibrary.BooksLibrary.Books.Commands.Fixtures;
|
using Lumina.Application.UnitTests.Core.WrittenContentLibrary.BooksLibrary.Books.Commands.Fixtures;
|
||||||
using Lumina.Contracts.Enums.BookLibrary;
|
using Lumina.Contracts.Enums.BookLibrary;
|
||||||
using Lumina.Domain.Common.Errors;
|
using Lumina.Domain.Common.Errors;
|
||||||
|
|||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
#region ========================================================================= USING =====================================================================================
|
#region ========================================================================= USING =====================================================================================
|
||||||
using AutoFixture;
|
using AutoFixture;
|
||||||
using Bogus;
|
using Bogus;
|
||||||
using Lumina.Application.Core.WrittenContentLibrary.BooksLibrary.Books.Commands;
|
using Lumina.Application.Core.WrittenContentLibrary.BooksLibrary.Books.Commands.AddBook;
|
||||||
using Lumina.Application.UnitTests.Common.Setup;
|
using Lumina.Application.UnitTests.Common.Setup;
|
||||||
using Lumina.Contracts.Enums.BookLibrary;
|
using Lumina.Contracts.Enums.BookLibrary;
|
||||||
using Lumina.Contracts.Models.Common;
|
using Lumina.Contracts.Models.Common;
|
||||||
|
|||||||
Reference in new issue
Block a user