2013-04-15 01:41:39 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2013-03-25 03:51:32 +00:00
|
|
|
|
using System.Linq;
|
2013-02-19 06:56:02 +00:00
|
|
|
|
using NzbDrone.Core.Datastore;
|
2013-09-11 06:33:47 +00:00
|
|
|
|
using NzbDrone.Core.Messaging;
|
2013-09-14 06:36:07 +00:00
|
|
|
|
using NzbDrone.Core.Messaging.Events;
|
2013-09-11 06:33:47 +00:00
|
|
|
|
|
2013-02-19 06:56:02 +00:00
|
|
|
|
|
|
|
|
|
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);
|
2013-04-15 01:41:39 +00:00
|
|
|
|
Series FindByTitle(string cleanTitle);
|
2013-03-02 18:25:39 +00:00
|
|
|
|
Series FindByTvdbId(int tvdbId);
|
2013-08-19 05:53:26 +00:00
|
|
|
|
Series FindByTvRageId(int tvRageId);
|
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-09-14 06:36:07 +00:00
|
|
|
|
public SeriesRepository(IDatabase database, IEventAggregator eventAggregator)
|
|
|
|
|
: base(database, eventAggregator)
|
2013-02-19 06:56:02 +00:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool SeriesPathExists(string path)
|
|
|
|
|
{
|
2013-03-27 03:44:52 +00:00
|
|
|
|
return Query.Any(c => c.Path == path);
|
2013-02-19 06:56:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-04-15 01:41:39 +00:00
|
|
|
|
public Series FindByTitle(string cleanTitle)
|
2013-02-19 06:56:02 +00:00
|
|
|
|
{
|
2013-04-15 01:41:39 +00:00
|
|
|
|
return Query.SingleOrDefault(s => s.CleanTitle.Equals(cleanTitle, StringComparison.InvariantCultureIgnoreCase));
|
2013-02-19 06:56:02 +00:00
|
|
|
|
}
|
2013-03-02 18:25:39 +00:00
|
|
|
|
|
|
|
|
|
public Series FindByTvdbId(int tvdbId)
|
|
|
|
|
{
|
2013-04-17 06:55:39 +00:00
|
|
|
|
return Query.SingleOrDefault(s => s.TvdbId.Equals(tvdbId));
|
2013-03-02 18:25:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-08-19 05:53:26 +00:00
|
|
|
|
public Series FindByTvRageId(int tvRageId)
|
|
|
|
|
{
|
|
|
|
|
return Query.SingleOrDefault(s => s.TvRageId.Equals(tvRageId));
|
|
|
|
|
}
|
|
|
|
|
|
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-27 06:16:55 +00:00
|
|
|
|
SetFields(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
|
|
|
|
}
|
|
|
|
|
}
|