Add repository interaction to CreateRecActionCommandHandler
Updated `CreateRecActionCommandHandler` to include a repository dependency (`IRepository<RecAction>`) for persisting data. Added a call to `repo.CreateAsync` in the `Handle` method to save the command request. Updated `using` directives to include necessary dependencies (`AutoMapper`, `DigitalData.Core.Abstraction.Application.Repository`, and `ReC.Domain.Entities`). Validation logic for `EndpointId` or `EndpointUri` remains unchanged.
This commit is contained in:
parent
606a6727f4
commit
3e6c2ea12b
@ -1,6 +1,8 @@
|
||||
using DigitalData.Core.Exceptions;
|
||||
using DigitalData.Core.Abstraction.Application.Repository;
|
||||
using DigitalData.Core.Exceptions;
|
||||
using MediatR;
|
||||
using ReC.Application.Endpoints.Commands;
|
||||
using ReC.Domain.Entities;
|
||||
|
||||
namespace ReC.Application.RecActions.Commands;
|
||||
|
||||
@ -21,7 +23,7 @@ public record CreateRecActionCommand : IRequest
|
||||
public string BodyQuery { get; init; } = null!;
|
||||
}
|
||||
|
||||
public class CreateRecActionCommandHandler(ISender sender) : IRequestHandler<CreateRecActionCommand>
|
||||
public class CreateRecActionCommandHandler(ISender sender, IRepository<RecAction> repo) : IRequestHandler<CreateRecActionCommand>
|
||||
{
|
||||
public async Task Handle(CreateRecActionCommand request, CancellationToken cancel)
|
||||
{
|
||||
@ -33,5 +35,7 @@ public class CreateRecActionCommandHandler(ISender sender) : IRequestHandler<Cre
|
||||
}
|
||||
else
|
||||
throw new BadRequestException("Either EndpointId or EndpointUri must be provided.");
|
||||
|
||||
await repo.CreateAsync(request, cancel);
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user