1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-12 11:15:43 +02:00

Fixes for Episode to EpisodeFile mapping.

Series details sorts with newest season and newest episode on top my default.
This commit is contained in:
markus101 2011-02-22 22:23:59 -08:00
parent ce6bcbfec1
commit 9d24ccd97a
6 changed files with 30 additions and 8 deletions

View File

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

View File

@ -23,5 +23,6 @@ public interface IEpisodeProvider
void RefreshEpisodeInfo(Season season);
IList<Episode> GetEpisodeBySeason(long seasonId);
void DeleteEpisode(int episodeId);
void UpdateEpisode(Episode episode);
}
}

View File

@ -75,17 +75,18 @@ public EpisodeFile ImportFile(Series series, string filePath)
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);

View File

@ -17,6 +17,6 @@ public class EpisodeFile
public DateTime DateAdded { get; set; }
[SubSonicToManyRelation]
public virtual List<Episode> Episodes { get; set; }
public virtual List<Episode> Episodes { get; private set; }
}
}

View File

@ -19,16 +19,20 @@ public class SeriesController : Controller
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 @@ public ActionResult Delete(int seriesId)
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 });
}
}
}

View File

@ -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">