2013-02-19 06:56:02 +00:00
|
|
|
|
using System.Collections.Generic;
|
2013-03-24 00:08:23 +00:00
|
|
|
|
using System.Data;
|
2013-02-19 06:56:02 +00:00
|
|
|
|
using NzbDrone.Core.Datastore;
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Tv
|
|
|
|
|
{
|
2013-03-24 04:16:00 +00:00
|
|
|
|
public interface ISeriesRepository : IBasicRepository<Series>
|
2013-02-19 06:56:02 +00:00
|
|
|
|
{
|
|
|
|
|
bool SeriesPathExists(string path);
|
|
|
|
|
List<Series> Search(string title);
|
2013-02-20 02:05:15 +00:00
|
|
|
|
Series GetByTitle(string cleanTitle);
|
2013-03-02 18:25:39 +00:00
|
|
|
|
Series FindByTvdbId(int tvdbId);
|
2013-03-04 05:53:02 +00:00
|
|
|
|
void SetSeriesType(int seriesId, SeriesTypes seriesTypes);
|
2013-02-19 06:56:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-03-24 04:16:00 +00:00
|
|
|
|
public class SeriesRepository : BasicRepository<Series>, ISeriesRepository
|
2013-02-19 06:56:02 +00:00
|
|
|
|
{
|
2013-03-24 00:08:23 +00:00
|
|
|
|
public SeriesRepository(IDbConnection database)
|
|
|
|
|
: base(database)
|
2013-02-19 06:56:02 +00:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool SeriesPathExists(string path)
|
|
|
|
|
{
|
2013-03-24 04:25:16 +00:00
|
|
|
|
return Any(c => c.Path == path);
|
2013-02-19 06:56:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<Series> Search(string title)
|
|
|
|
|
{
|
2013-03-24 04:25:16 +00:00
|
|
|
|
return Where(s => s.Title.Contains(title));
|
2013-02-19 06:56:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-02-20 02:05:15 +00:00
|
|
|
|
public Series GetByTitle(string cleanTitle)
|
2013-02-19 06:56:02 +00:00
|
|
|
|
{
|
2013-03-24 04:25:16 +00:00
|
|
|
|
return SingleOrDefault(s => s.CleanTitle.Equals(cleanTitle));
|
2013-02-19 06:56:02 +00:00
|
|
|
|
}
|
2013-03-02 18:25:39 +00:00
|
|
|
|
|
|
|
|
|
public Series FindByTvdbId(int tvdbId)
|
|
|
|
|
{
|
2013-03-24 04:25:16 +00:00
|
|
|
|
return SingleOrDefault(s => s.TvDbId.Equals(tvdbId));
|
2013-03-02 18:25:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-03-24 00:08:23 +00:00
|
|
|
|
public void SetSeriesType(int seriesId, SeriesTypes seriesType)
|
2013-03-02 18:25:39 +00:00
|
|
|
|
{
|
2013-03-24 04:25:16 +00:00
|
|
|
|
UpdateFields(new Series { Id = seriesId, SeriesType = seriesType }, s => s.SeriesType);
|
2013-03-02 18:25:39 +00:00
|
|
|
|
}
|
2013-02-19 06:56:02 +00:00
|
|
|
|
}
|
|
|
|
|
}
|