Remove provider status on provider deletion

This commit is contained in:
Bogdan 2024-08-19 04:58:10 +03:00 committed by GitHub
parent 911a3d4c1e
commit f45713bff8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 6 deletions

View File

@ -8,6 +8,7 @@ namespace NzbDrone.Core.ThingiProvider.Status
where TModel : ProviderStatusBase, new()
{
TModel FindByProviderId(int providerId);
void DeleteByProviderId(int providerId);
}
public class ProviderStatusRepository<TModel> : BasicRepository<TModel>, IProviderStatusRepository<TModel>
@ -22,5 +23,10 @@ namespace NzbDrone.Core.ThingiProvider.Status
{
return Query(c => c.ProviderId == providerId).SingleOrDefault();
}
public void DeleteByProviderId(int providerId)
{
Delete(c => c.ProviderId == providerId);
}
}
}

View File

@ -151,12 +151,7 @@ namespace NzbDrone.Core.ThingiProvider.Status
public virtual void HandleAsync(ProviderDeletedEvent<TProvider> message)
{
var providerStatus = _providerStatusRepository.FindByProviderId(message.ProviderId);
if (providerStatus != null)
{
_providerStatusRepository.Delete(providerStatus);
}
_providerStatusRepository.DeleteByProviderId(message.ProviderId);
}
}
}