1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-05 10:32:35 +01:00
Radarr/NzbDrone.Core/Tv/SeriesRepository.cs

50 lines
1.4 KiB
C#
Raw Normal View History

2013-02-19 07:56:02 +01:00
using System.Collections.Generic;
using System.Linq;
using NzbDrone.Common;
using NzbDrone.Core.Datastore;
namespace NzbDrone.Core.Tv
{
public interface ISeriesRepository : IBasicRepository<Series>
{
bool SeriesPathExists(string path);
List<Series> Search(string title);
Series GetByTitle(string cleanTitle);
2013-03-02 19:25:39 +01:00
Series FindByTvdbId(int tvdbId);
void SetSeriesType(int seriesId, SeriesTypes seriesTypes);
2013-03-02 19:25:39 +01:00
2013-02-19 07:56:02 +01:00
}
public class SeriesRepository : BasicRepository<Series>, ISeriesRepository
{
public SeriesRepository(IObjectDatabase objectDatabase)
: base(objectDatabase)
{
}
public bool SeriesPathExists(string path)
{
return Queryable.Any(s => DiskProvider.PathEquals(s.Path, path));
}
public List<Series> Search(string title)
{
return Queryable.Where(s => s.Title.Contains(title)).ToList();
}
public Series GetByTitle(string cleanTitle)
2013-02-19 07:56:02 +01:00
{
return Queryable.SingleOrDefault(s => s.CleanTitle.Equals(cleanTitle));
}
2013-03-02 19:25:39 +01:00
public Series FindByTvdbId(int tvdbId)
{
return Queryable.SingleOrDefault(s => s.TvDbId == tvdbId);
}
public void SetSeriesType(int seriesId, SeriesTypes seriesTypes)
2013-03-02 19:25:39 +01:00
{
ObjectDatabase.UpdateField(new Series(){Id = seriesId, SeriesTypes =seriesTypes }, "SeriesType");
2013-03-02 19:25:39 +01:00
}
2013-02-19 07:56:02 +01:00
}
}