namespace DocuMed.Repository.Handlers.Hospitals; public class DeleteHospitalCommandHandler(IRepositoryWrapper repositoryWrapper) : IRequestHandler { public async Task Handle(DeleteHospitalCommand request, CancellationToken cancellationToken) { var ent = await repositoryWrapper.SetRepository().TableNoTracking .FirstOrDefaultAsync(h => h.Id == request.Id, cancellationToken); if (ent == null) throw new BaseApiException(ApiResultStatusCode.NotFound, "Hospital not found"); repositoryWrapper.SetRepository().Delete(ent); await repositoryWrapper.SaveChangesAsync(cancellationToken); return ent.Id; } }