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);
|
||||
}
|
15
Femto.Modules.Media/Application/MediaContext.cs
Normal file
15
Femto.Modules.Media/Application/MediaContext.cs
Normal file
|
@ -0,0 +1,15 @@
|
|||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Femto.Modules.Media.Data;
|
||||
|
||||
internal class MediaContext(DbContextOptions<MediaContext> options) : DbContext(options)
|
||||
{
|
||||
public virtual DbSet<SavedBlob> SavedBlobs { get; set; }
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder builder)
|
||||
{
|
||||
base.OnModelCreating(builder);
|
||||
builder.HasDefaultSchema("media");
|
||||
builder.ApplyConfigurationsFromAssembly(typeof(MediaContext).Assembly);
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
22
Femto.Modules.Media/Application/SavedBlob.cs
Normal file
22
Femto.Modules.Media/Application/SavedBlob.cs
Normal file
|
@ -0,0 +1,22 @@
|
|||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Femto.Modules.Media.Data;
|
||||
|
||||
[Table("saved_blob")]
|
||||
internal class SavedBlob
|
||||
{
|
||||
public Guid Id { get; private set; }
|
||||
public DateTime UploadedOn { get; private set; }
|
||||
public string Type { get; private set; }
|
||||
public long? Size { get; private set; }
|
||||
|
||||
public SavedBlob(Guid id, string type, long? size)
|
||||
{
|
||||
Id = id;
|
||||
UploadedOn = DateTime.UtcNow;
|
||||
Type = type;
|
||||
Size = size;
|
||||
}
|
||||
|
||||
private SavedBlob() { }
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue