Adds initial ASP.NET Core MVC replacement for Blazor WASM

This commit is contained in:
BinaryAlley committed 2024-09-26 19:58:08 +03:00
1 parent 5409200c7a
commit 193861c9c5
56 files changed
+505 -4139

No files matched your search

@@ -0,0 +1,27 @@
#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
{
#region ===================================================================== METHODS ===================================================================================
/// <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);
}
#endregion
}
@@ -0,0 +1,14 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using Lumina.Contracts.Responses.FileManagement;
using Mediator;
#endregion
namespace Lumina.Application.Core.FileManagement.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>>;
@@ -0,0 +1,47 @@
#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 Mapster;
using Mediator;
using System.Threading;
using System.Threading.Tasks;
#endregion
namespace Lumina.Application.Core.FileManagement.Thumbnails.Queries.GetThumbnail;
/// <summary>
/// Handler for the query to get the file thumbnail.
/// </summary>
public class GetThumbnailQueryHandler : IRequestHandler<GetThumbnailQuery, ErrorOr<ThumbnailResponse>>
{
#region ================================================================== FIELD MEMBERS ================================================================================
private readonly IThumbnailService _thumbnailsService;
#endregion
#region ====================================================================== CTOR =====================================================================================
/// <summary>
/// Initializes a new instance of the <see cref="GetThumbnailQueryHandler"/> class.
/// </summary>
/// <param name="thumbnailsService">Injected service for handling thumbnails.</param>
public GetThumbnailQueryHandler(IThumbnailService thumbnailsService)
{
_thumbnailsService = thumbnailsService;
}
#endregion
#region ===================================================================== METHODS ===================================================================================
/// <summary>
/// Gets the thumbnail for a file located at the specified path, with the specified quality.
/// </summary>
/// <param name="request">The query to be handled.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <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(result.Value.Adapt<ThumbnailResponse>()), errors => errors));
}
#endregion
}