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

52 lines
1.5 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using NzbDrone.Core.Datastore;
using NzbDrone.Core.Messaging;
using NzbDrone.Core.Messaging.Events;
namespace NzbDrone.Core.Tv
{
public interface ISeriesRepository : IBasicRepository<Series>
{
bool SeriesPathExists(string path);
Series FindByTitle(string cleanTitle);
Series FindByTvdbId(int tvdbId);
Series FindByTvRageId(int tvRageId);
void SetSeriesType(int seriesId, SeriesTypes seriesTypes);
}
public class SeriesRepository : BasicRepository<Series>, ISeriesRepository
{
public SeriesRepository(IDatabase database, IEventAggregator eventAggregator)
: base(database, eventAggregator)
{
}
public bool SeriesPathExists(string path)
{
return Query.Any(c => c.Path == path);
}
public Series FindByTitle(string cleanTitle)
{
return Query.SingleOrDefault(s => s.CleanTitle.Equals(cleanTitle, StringComparison.InvariantCultureIgnoreCase));
}
public Series FindByTvdbId(int tvdbId)
{
return Query.SingleOrDefault(s => s.TvdbId.Equals(tvdbId));
}
public Series FindByTvRageId(int tvRageId)
{
return Query.SingleOrDefault(s => s.TvRageId.Equals(tvRageId));
}
public void SetSeriesType(int seriesId, SeriesTypes seriesType)
{
SetFields(new Series { Id = seriesId, SeriesType = seriesType }, s => s.SeriesType);
}
}
}