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