Refactor RecActionController and DeleteRecActionsCommand

Updated the `Invoke` method in `RecActionController` to use `cmd` as the route parameter instead of `profileId`, modifying the HTTP POST route to `invoke/{cmd}`.

Refactored the `Delete` method to accept a `DeleteRecActionsCommand` object (`cmd`) instead of `profileId`. Removed the hardcoded `ProfileId` assignment and passed the `cmd` object directly to `mediator.Send`.

Made the `ProfileId` property in `DeleteRecActionsCommand` required by removing its default value, enforcing explicit initialization. This improves validation and ensures flexibility for future enhancements.

These changes enhance the API's clarity, flexibility, and maintainability.
This commit is contained in:
2025-12-04 15:37:06 +01:00
parent f9c0a8be55
commit 9a12643eb6
2 changed files with 5 additions and 9 deletions

View File

@@ -8,7 +8,7 @@ namespace ReC.Application.RecActions.Commands;
public class DeleteRecActionsCommand : IRequest
{
public long ProfileId { get; init; } = 2;
public required long ProfileId { get; init; }
}
public class DeleteRecActionsCommandHandler(IRepository<RecAction> repo) : IRequestHandler<DeleteRecActionsCommand>