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.
Lidarr/NzbDrone.Core/Tv/SeriesRepository.cs

62 lines
1.8 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using NzbDrone.Common.Messaging;
12 years ago
using NzbDrone.Core.Datastore;
namespace NzbDrone.Core.Tv
{
12 years ago
public interface ISeriesRepository : IBasicRepository<Series>
12 years ago
{
bool SeriesPathExists(string path);
List<Series> Search(string title);
Series FindByTitle(string cleanTitle);
12 years ago
Series FindByTvdbId(int tvdbId);
void SetSeriesType(int seriesId, SeriesTypes seriesTypes);
Series FindBySlug(string slug);
List<String> GetSeriesPaths();
12 years ago
}
12 years ago
public class SeriesRepository : BasicRepository<Series>, ISeriesRepository
12 years ago
{
public SeriesRepository(IDatabase database, IMessageAggregator messageAggregator)
: base(database, messageAggregator)
12 years ago
{
}
public bool SeriesPathExists(string path)
{
return Query.Any(c => c.Path == path);
12 years ago
}
public List<Series> Search(string title)
{
return Query.Where(s => s.Title.Contains(title));
12 years ago
}
public Series FindByTitle(string cleanTitle)
12 years ago
{
return Query.SingleOrDefault(s => s.CleanTitle.Equals(cleanTitle, StringComparison.InvariantCultureIgnoreCase));
12 years ago
}
12 years ago
public Series FindByTvdbId(int tvdbId)
{
return Query.SingleOrDefault(s => s.TvdbId.Equals(tvdbId));
12 years ago
}
public void SetSeriesType(int seriesId, SeriesTypes seriesType)
12 years ago
{
SetFields(new Series { Id = seriesId, SeriesType = seriesType }, s => s.SeriesType);
12 years ago
}
public Series FindBySlug(string slug)
{
return Query.SingleOrDefault(c => c.TitleSlug == slug.ToLower());
}
public List<string> GetSeriesPaths()
{
return Query.Select(s => s.Path).ToList();
}
12 years ago
}
}