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

50 lines
1.5 KiB

12 years ago
using System.Collections.Generic;
using System.Data;
12 years ago
using System.Linq;
using NzbDrone.Core.Datastore;
using ServiceStack.OrmLite;
12 years ago
namespace NzbDrone.Core.Tv
{
public interface ISeriesRepository : IBasicDb<Series>
12 years ago
{
bool SeriesPathExists(string path);
List<Series> Search(string title);
Series GetByTitle(string cleanTitle);
12 years ago
Series FindByTvdbId(int tvdbId);
void SetSeriesType(int seriesId, SeriesTypes seriesTypes);
12 years ago
}
public class SeriesRepository : BasicDb<Series>, ISeriesRepository
12 years ago
{
public SeriesRepository(IDbConnection database)
: base(database)
12 years ago
{
}
public bool SeriesPathExists(string path)
{
return Database.Exists<Series>("WHERE Path = {0}", path);
12 years ago
}
public List<Series> Search(string title)
{
return Database.Select<Series>(s => s.Title.Contains(title));
12 years ago
}
public Series GetByTitle(string cleanTitle)
12 years ago
{
return Database.Select<Series>(s => s.CleanTitle.Equals(cleanTitle)).SingleOrDefault();
12 years ago
}
12 years ago
public Series FindByTvdbId(int tvdbId)
{
return Database.Select<Series>(s => s.TvDbId.Equals(tvdbId)).SingleOrDefault();
12 years ago
}
public void SetSeriesType(int seriesId, SeriesTypes seriesType)
12 years ago
{
Database.UpdateOnly(new Series { SeriesType = seriesType }, s => s.SeriesType, s => s.Id == seriesId);
12 years ago
}
12 years ago
}
}