Fixes for Episode to EpisodeFile mapping.

Series details sorts with newest season and newest episode on top my default.
pull/4/head
markus101 14 years ago
parent ce6bcbfec1
commit 9d24ccd97a

@ -263,6 +263,11 @@ namespace NzbDrone.Core.Providers
_sonicRepo.Delete<Episode>(episodeId); _sonicRepo.Delete<Episode>(episodeId);
} }
public void UpdateEpisode(Episode episode)
{
_sonicRepo.Update(episode);
}
private bool IsSeasonIgnored(EpisodeModel episode) private bool IsSeasonIgnored(EpisodeModel episode)
{ {
//Check if this Season is ignored //Check if this Season is ignored

@ -23,5 +23,6 @@ namespace NzbDrone.Core.Providers
void RefreshEpisodeInfo(Season season); void RefreshEpisodeInfo(Season season);
IList<Episode> GetEpisodeBySeason(long seasonId); IList<Episode> GetEpisodeBySeason(long seasonId);
void DeleteEpisode(int episodeId); void DeleteEpisode(int episodeId);
void UpdateEpisode(Episode episode);
} }
} }

@ -75,17 +75,18 @@ namespace NzbDrone.Core.Providers
var episodeFile = new EpisodeFile(); var episodeFile = new EpisodeFile();
episodeFile.DateAdded = DateTime.Now; episodeFile.DateAdded = DateTime.Now;
episodeFile.SeriesId = series.SeriesId; episodeFile.SeriesId = series.SeriesId;
episodeFile.Episodes = episodes;
episodeFile.Path = Parser.NormalizePath(filePath); episodeFile.Path = Parser.NormalizePath(filePath);
episodeFile.Size = _diskProvider.GetSize(filePath); episodeFile.Size = _diskProvider.GetSize(filePath);
episodeFile.Quality = Parser.ParseQuality(filePath); episodeFile.Quality = Parser.ParseQuality(filePath);
episodeFile.Proper = Parser.ParseProper(filePath); episodeFile.Proper = Parser.ParseProper(filePath);
_repository.Add(episodeFile); var fileId = (int)_repository.Add(episodeFile);
//This is for logging, a little ugly... //This is for logging + updating the episodes that are linked to this EpisodeFile
string episodeList = String.Empty; string episodeList = String.Empty;
foreach (var ep in episodes) foreach (var ep in episodes)
{ {
ep.FileId = fileId;
_episodeProvider.UpdateEpisode(ep);
episodeList += String.Format(", {0}", ep.EpisodeId).Trim(' ', ','); episodeList += String.Format(", {0}", ep.EpisodeId).Trim(' ', ',');
} }
Logger.Trace("File {0}:{1} attached to episode(s): '{2}'", episodeFile.FileId, filePath, episodeList); Logger.Trace("File {0}:{1} attached to episode(s): '{2}'", episodeFile.FileId, filePath, episodeList);

@ -17,6 +17,6 @@ namespace NzbDrone.Core.Repository
public DateTime DateAdded { get; set; } public DateTime DateAdded { get; set; }
[SubSonicToManyRelation] [SubSonicToManyRelation]
public virtual List<Episode> Episodes { get; set; } public virtual List<Episode> Episodes { get; private set; }
} }
} }

@ -19,16 +19,20 @@ namespace NzbDrone.Web.Controllers
private readonly ISyncProvider _syncProvider; private readonly ISyncProvider _syncProvider;
private readonly IRssSyncProvider _rssSyncProvider; private readonly IRssSyncProvider _rssSyncProvider;
private readonly IQualityProvider _qualityProvider; private readonly IQualityProvider _qualityProvider;
private readonly IMediaFileProvider _mediaFileProvider;
// //
// GET: /Series/ // GET: /Series/
public SeriesController(ISyncProvider syncProvider, ISeriesProvider seriesProvider, IEpisodeProvider episodeProvider, IRssSyncProvider rssSyncProvider, IQualityProvider qualityProvider) public SeriesController(ISyncProvider syncProvider, ISeriesProvider seriesProvider,
IEpisodeProvider episodeProvider, IRssSyncProvider rssSyncProvider,
IQualityProvider qualityProvider, IMediaFileProvider mediaFileProvider)
{ {
_seriesProvider = seriesProvider; _seriesProvider = seriesProvider;
_episodeProvider = episodeProvider; _episodeProvider = episodeProvider;
_syncProvider = syncProvider; _syncProvider = syncProvider;
_rssSyncProvider = rssSyncProvider; _rssSyncProvider = rssSyncProvider;
_qualityProvider = qualityProvider; _qualityProvider = qualityProvider;
_mediaFileProvider = mediaFileProvider;
} }
public ActionResult Index() public ActionResult Index()
@ -189,5 +193,14 @@ namespace NzbDrone.Web.Controllers
return RedirectToAction("Index", "Series"); return RedirectToAction("Index", "Series");
} }
public ActionResult SyncEpisodesOnDisk(int seriesId)
{
//Syncs the episodes on disk for the specified series
var series = _seriesProvider.GetSeries(seriesId);
_mediaFileProvider.Scan(series);
return RedirectToAction("Details", new { seriesId });
}
} }
} }

@ -33,10 +33,11 @@
<div class="display-field"> <div class="display-field">
<%: Model.Path %></div> <%: Model.Path %></div>
</fieldset> </fieldset>
<% <%
//Todo: This breaks when using SQLServer... thoughts? //Todo: This breaks when using SQLServer... thoughts?
//Normal Seasons //Normal Seasons
foreach (var season in Model.Seasons.Where(s => s.SeasonNumber > 0)) foreach (var season in Model.Seasons.Where(s => s.SeasonNumber > 0).Reverse())
{ {
%> %>
<br /> <br />
@ -55,7 +56,7 @@
}) })
//.DetailView(detailView => detailView.Template(e => Html.RenderPartial("EpisodeDetail", e))) //.DetailView(detailView => detailView.Template(e => Html.RenderPartial("EpisodeDetail", e)))
.DetailView(detailView => detailView.ClientTemplate("<div><#= Overview #></div>")) .DetailView(detailView => detailView.ClientTemplate("<div><#= Overview #></div>"))
.Sortable(rows => rows.OrderBy(epSort => epSort.Add(c => c.EpisodeNumber)).Enabled(false)) .Sortable(rows => rows.OrderBy(epSort => epSort.Add(c => c.EpisodeNumber).Descending()).Enabled(true))
.Footer(false) .Footer(false)
.DataBinding(d => d.Ajax().Select("_AjaxSeasonGrid", "Series", new RouteValueDictionary { { "seasonId", season1.SeasonId.ToString() } })) .DataBinding(d => d.Ajax().Select("_AjaxSeasonGrid", "Series", new RouteValueDictionary { { "seasonId", season1.SeasonId.ToString() } }))
//.EnableCustomBinding(true) //.EnableCustomBinding(true)
@ -89,7 +90,8 @@ Html.Telerik().Grid(specialSeasons.Episodes).Name("seasons_specials")
%> %>
<p> <p>
<%: Html.ActionLink("Edit", "Edit", new {seriesId = Model.SeriesId}) %> | <%: Html.ActionLink("Edit", "Edit", new {seriesId = Model.SeriesId}) %> |
<%: Html.ActionLink("Back to Series", "Index") %> <%: Html.ActionLink("Back to Series List", "Index") %> |
<%: Html.ActionLink("Sync Episodes on Disk", "SyncEpisodesOnDisk", new {seriesId = Model.SeriesId}) %>
</p> </p>
</asp:Content> </asp:Content>
<asp:Content ContentPlaceHolderID="Scripts" runat="server"> <asp:Content ContentPlaceHolderID="Scripts" runat="server">

Loading…
Cancel
Save