namespace Brizco.Repository.Handlers.ShiftPlan; public class DeleteShiftPlanCommandHandler : IRequestHandler { private readonly IRepositoryWrapper _repositoryWrapper; public DeleteShiftPlanCommandHandler(IRepositoryWrapper repositoryWrapper) { _repositoryWrapper = repositoryWrapper; } public async Task Handle(DeleteShiftPlanCommand request, CancellationToken cancellationToken) { var shiftPlan = await _repositoryWrapper.SetRepository() .TableNoTracking.FirstOrDefaultAsync(s => s.Id == request.Id); if (shiftPlan == null) throw new AppException("ShiftPlan not found", ApiResultStatusCode.NotFound); _repositoryWrapper.SetRepository() .Delete(shiftPlan); await _repositoryWrapper.SaveChangesAsync(cancellationToken); return true; } }