wip
This commit is contained in:
parent
1ecaf64dea
commit
cb9d5e332e
11 changed files with 72 additions and 69 deletions
|
@ -4,6 +4,6 @@ namespace Femto.Modules.Media.Application;
|
|||
|
||||
public interface IMediaModule
|
||||
{
|
||||
Task<TResult> PostCommand<TResult>(ICommand<TResult> command);
|
||||
Task<TResult> PostQuery<TResult>(IQuery<TResult> query);
|
||||
Task<TResult> PostCommand<TResult>(ICommand<TResult> command, CancellationToken cancellationToken = default);
|
||||
Task<TResult> PostQuery<TResult>(IQuery<TResult> query, CancellationToken cancellationToken = default);
|
||||
}
|
|
@ -5,21 +5,21 @@ using Microsoft.Extensions.Hosting;
|
|||
|
||||
namespace Femto.Modules.Media.Application;
|
||||
|
||||
public class MediaModule(IHost host) : IMediaModule
|
||||
internal class MediaModule(IHost host) : IMediaModule
|
||||
{
|
||||
public async Task<TResult> PostCommand<TResult>(ICommand<TResult> command)
|
||||
public async Task<TResult> PostCommand<TResult>(ICommand<TResult> command, CancellationToken cancellationToken)
|
||||
{
|
||||
using var scope = host.Services.CreateScope();
|
||||
var mediator = scope.ServiceProvider.GetRequiredService<IMediator>();
|
||||
var response = await mediator.Send(command);
|
||||
var response = await mediator.Send(command, cancellationToken);
|
||||
return response;
|
||||
}
|
||||
|
||||
public async Task<TResult> PostQuery<TResult>(IQuery<TResult> query)
|
||||
public async Task<TResult> PostQuery<TResult>(IQuery<TResult> query, CancellationToken cancellationToken)
|
||||
{
|
||||
using var scope = host.Services.CreateScope();
|
||||
var mediator = scope.ServiceProvider.GetRequiredService<IMediator>();
|
||||
var response = await mediator.Send(query);
|
||||
var response = await mediator.Send(query, cancellationToken);
|
||||
return response;
|
||||
}
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
using Femto.Common.Domain;
|
||||
using Femto.Modules.Media.Contracts.LoadFile.Dto;
|
||||
using MediatR;
|
||||
|
||||
namespace Femto.Modules.Media.Contracts.LoadFile;
|
||||
|
||||
public record LoadFileQuery(Guid FileId) : IRequest<LoadFileQueryResult>;
|
||||
public record LoadFileQuery(Guid FileId) : IQuery<LoadFileQueryResult>;
|
|
@ -1,5 +1,6 @@
|
|||
using Femto.Common.Domain;
|
||||
using MediatR;
|
||||
|
||||
namespace Femto.Modules.Media.Contracts.SaveFile;
|
||||
|
||||
public record SaveFileCommand(Stream Data, string ContentType, long? ContentLength) : IRequest<Guid>;
|
||||
public record SaveFileCommand(Stream Data, string ContentType, long? ContentLength) : ICommand<Guid>;
|
Loading…
Add table
Add a link
Reference in a new issue