- Replaced instances of the previous messaging system with LiteCqrs across various application components, enhancing the CQRS implementation. - Updated dependency injection to register LiteCqrs services and behaviors, streamlining command and query handling. - Adjusted multiple command and query handlers to align with the new messaging framework, ensuring consistent functionality and improved maintainability. - Added LiteCqrs package reference in the project file for better dependency management.
27 lines
806 B
C#
27 lines
806 B
C#
using Microsoft.EntityFrameworkCore;
|
|
using PnvPanel.Application.Common.Interfaces;
|
|
using LiteCqrs;
|
|
using PnvPanel.Application.Common.Models;
|
|
|
|
namespace PnvPanel.Application.Admin.Instructions;
|
|
|
|
public sealed class DeleteInstructionTabCommandHandler(IAppDbContext dbContext)
|
|
: ICommandHandler<DeleteInstructionTabCommand, Result>
|
|
{
|
|
public async Task<Result> Handle(
|
|
DeleteInstructionTabCommand command,
|
|
CancellationToken cancellationToken
|
|
)
|
|
{
|
|
var tab = await dbContext.InstructionTabs.FirstOrDefaultAsync(
|
|
t => t.Id == command.TabId,
|
|
cancellationToken
|
|
);
|
|
if (tab is null)
|
|
return Result.Failure(InstructionErrors.TabNotFound);
|
|
|
|
dbContext.InstructionTabs.Remove(tab);
|
|
return Result.Success();
|
|
}
|
|
}
|