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);
}
public void UpdateEpisode(Episode episode)
{
_sonicRepo.Update(episode);
}
private bool IsSeasonIgnored(EpisodeModel episode)
{
//Check if this Season is ignored

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

@ -75,17 +75,18 @@ namespace NzbDrone.Core.Providers
var episodeFile = new EpisodeFile();
episodeFile.DateAdded = DateTime.Now;
episodeFile.SeriesId = series.SeriesId;
episodeFile.Episodes = episodes;
episodeFile.Path = Parser.NormalizePath(filePath);
episodeFile.Size = _diskProvider.GetSize(filePath);
episodeFile.Quality = Parser.ParseQuality(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;
foreach (var ep in episodes)
{
ep.FileId = fileId;
_episodeProvider.UpdateEpisode(ep);
episodeList += String.Format(", {0}", ep.EpisodeId).Trim(' ', ',');
}
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; }
[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 IRssSyncProvider _rssSyncProvider;
private readonly IQualityProvider _qualityProvider;
private readonly IMediaFileProvider _mediaFileProvider;
//
// 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;
_episodeProvider = episodeProvider;
_syncProvider = syncProvider;
_rssSyncProvider = rssSyncProvider;
_qualityProvider = qualityProvider;
_mediaFileProvider = mediaFileProvider;
}
public ActionResult Index()
@ -189,5 +193,14 @@ namespace NzbDrone.Web.Controllers
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">
<%: Model.Path %></div>
</fieldset>
<%
//Todo: This breaks when using SQLServer... thoughts?
//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 />
@ -55,7 +56,7 @@
})
//.DetailView(detailView => detailView.Template(e => Html.RenderPartial("EpisodeDetail", e)))
.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)
.DataBinding(d => d.Ajax().Select("_AjaxSeasonGrid", "Series", new RouteValueDictionary { { "seasonId", season1.SeasonId.ToString() } }))
//.EnableCustomBinding(true)
@ -89,7 +90,8 @@ Html.Telerik().Grid(specialSeasons.Episodes).Name("seasons_specials")
%>
<p>
<%: 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>
</asp:Content>
<asp:Content ContentPlaceHolderID="Scripts" runat="server">

Loading…
Cancel
Save