You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
1.1 KiB
41 lines
1.1 KiB
using System.Linq;
|
|
using NzbDrone.Core.Datastore;
|
|
using NzbDrone.Core.Messaging.Events;
|
|
|
|
namespace NzbDrone.Core.Music
|
|
{
|
|
public interface IArtistRepository : IBasicRepository<Artist>
|
|
{
|
|
bool ArtistPathExists(string path);
|
|
Artist FindByName(string cleanTitle);
|
|
Artist FindByItunesId(int iTunesId);
|
|
}
|
|
|
|
public class ArtistRepository : BasicRepository<Artist>, IArtistRepository
|
|
{
|
|
public ArtistRepository(IMainDatabase database, IEventAggregator eventAggregator)
|
|
: base(database, eventAggregator)
|
|
{
|
|
}
|
|
|
|
|
|
public bool ArtistPathExists(string path)
|
|
{
|
|
return Query.Where(c => c.Path == path).Any();
|
|
}
|
|
|
|
public Artist FindByItunesId(int iTunesId)
|
|
{
|
|
return Query.Where(s => s.ItunesId == iTunesId).SingleOrDefault();
|
|
}
|
|
|
|
public Artist FindByName(string cleanName)
|
|
{
|
|
cleanName = cleanName.ToLowerInvariant();
|
|
|
|
return Query.Where(s => s.CleanTitle == cleanName)
|
|
.SingleOrDefault();
|
|
}
|
|
}
|
|
}
|