mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2025-09-17 17:14:18 +02:00
Add Find()
to BasicRepository
This commit is contained in:
@@ -16,6 +16,7 @@ namespace NzbDrone.Core.Datastore
|
|||||||
{
|
{
|
||||||
IEnumerable<TModel> All();
|
IEnumerable<TModel> All();
|
||||||
int Count();
|
int Count();
|
||||||
|
TModel Find(int id);
|
||||||
TModel Get(int id);
|
TModel Get(int id);
|
||||||
TModel Insert(TModel model);
|
TModel Insert(TModel model);
|
||||||
TModel Update(TModel model);
|
TModel Update(TModel model);
|
||||||
@@ -87,10 +88,17 @@ namespace NzbDrone.Core.Datastore
|
|||||||
return Query(Builder());
|
return Query(Builder());
|
||||||
}
|
}
|
||||||
|
|
||||||
public TModel Get(int id)
|
public TModel Find(int id)
|
||||||
{
|
{
|
||||||
var model = Query(x => x.Id == id).FirstOrDefault();
|
var model = Query(x => x.Id == id).FirstOrDefault();
|
||||||
|
|
||||||
|
return model;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TModel Get(int id)
|
||||||
|
{
|
||||||
|
var model = Find(id);
|
||||||
|
|
||||||
if (model == null)
|
if (model == null)
|
||||||
{
|
{
|
||||||
throw new ModelNotFoundException(typeof(TModel), id);
|
throw new ModelNotFoundException(typeof(TModel), id);
|
||||||
|
@@ -9,6 +9,8 @@ namespace NzbDrone.Core.ThingiProvider
|
|||||||
{
|
{
|
||||||
List<TProviderDefinition> All();
|
List<TProviderDefinition> All();
|
||||||
List<TProvider> GetAvailableProviders();
|
List<TProvider> GetAvailableProviders();
|
||||||
|
bool Exists(int id);
|
||||||
|
TProviderDefinition Find(int id);
|
||||||
TProviderDefinition Get(int id);
|
TProviderDefinition Get(int id);
|
||||||
TProviderDefinition Create(TProviderDefinition definition);
|
TProviderDefinition Create(TProviderDefinition definition);
|
||||||
void Update(TProviderDefinition definition);
|
void Update(TProviderDefinition definition);
|
||||||
|
@@ -91,11 +91,21 @@ namespace NzbDrone.Core.ThingiProvider
|
|||||||
return Active().Select(GetInstance).ToList();
|
return Active().Select(GetInstance).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool Exists(int id)
|
||||||
|
{
|
||||||
|
return _providerRepository.Find(id) != null;
|
||||||
|
}
|
||||||
|
|
||||||
public virtual TProviderDefinition Get(int id)
|
public virtual TProviderDefinition Get(int id)
|
||||||
{
|
{
|
||||||
return _providerRepository.Get(id);
|
return _providerRepository.Get(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public TProviderDefinition Find(int id)
|
||||||
|
{
|
||||||
|
return _providerRepository.Find(id);
|
||||||
|
}
|
||||||
|
|
||||||
public virtual TProviderDefinition Create(TProviderDefinition definition)
|
public virtual TProviderDefinition Create(TProviderDefinition definition)
|
||||||
{
|
{
|
||||||
var result = _providerRepository.Insert(definition);
|
var result = _providerRepository.Insert(definition);
|
||||||
|
Reference in New Issue
Block a user