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