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

New: Upcoming page is now broken down by day.

This commit is contained in:
Mark McDowall 2012-05-17 18:14:44 -07:00
parent edb0b3af86
commit ac2f3399f0
4 changed files with 125 additions and 18 deletions

View File

@ -36,10 +36,9 @@ public virtual List<Episode> Tomorrow()
public virtual List<Episode> Week() public virtual List<Episode> Week()
{ {
return RecentEpisodes().Where(c => c.AirDate >= DateTime.Today.AddDays(2).Date).ToList(); return RecentEpisodes().Where(c => c.AirDate >= DateTime.Today.AddDays(2).Date).ToList();
} }
private List<Episode> RecentEpisodes() public virtual List<Episode> RecentEpisodes()
{ {
return _database.Fetch<Episode, Series>(@"SELECT * FROM Episodes return _database.Fetch<Episode, Series>(@"SELECT * FROM Episodes
INNER JOIN Series ON Episodes.SeriesId = Series.SeriesId INNER JOIN Series ON Episodes.SeriesId = Series.SeriesId

View File

@ -23,12 +23,20 @@ public UpcomingController(UpcomingEpisodesProvider upcomingEpisodesProvider)
public ActionResult Index() public ActionResult Index()
{ {
var upcomingEpisodes = GetUpcomingEpisodeModels(_upcomingEpisodesProvider.RecentEpisodes());
var upcoming = new UpcomingEpisodesModel var upcoming = new UpcomingEpisodesModel
{ {
Yesterday = GetUpcomingEpisodeModels(_upcomingEpisodesProvider.Yesterday()), Yesterday = upcomingEpisodes.Where(e => e.AirDateTime.Date == DateTime.Today.AddDays(-1)).ToList(),
Today = GetUpcomingEpisodeModels(_upcomingEpisodesProvider.Today()), Today = upcomingEpisodes.Where(e => e.AirDateTime.Date == DateTime.Today).ToList(),
Tomorrow = GetUpcomingEpisodeModels(_upcomingEpisodesProvider.Tomorrow()), Tomorrow = upcomingEpisodes.Where(e => e.AirDateTime.Date == DateTime.Today.AddDays(1)).ToList(),
Week = GetUpcomingEpisodeModels(_upcomingEpisodesProvider.Week()) TwoDays = upcomingEpisodes.Where(e => e.AirDateTime.Date == DateTime.Today.AddDays(2)).ToList(),
ThreeDays = upcomingEpisodes.Where(e => e.AirDateTime.Date == DateTime.Today.AddDays(3)).ToList(),
FourDays = upcomingEpisodes.Where(e => e.AirDateTime.Date == DateTime.Today.AddDays(4)).ToList(),
FiveDays = upcomingEpisodes.Where(e => e.AirDateTime.Date == DateTime.Today.AddDays(5)).ToList(),
SixDays = upcomingEpisodes.Where(e => e.AirDateTime.Date == DateTime.Today.AddDays(6)).ToList(),
Later = upcomingEpisodes.Where(e => e.AirDateTime.Date >= DateTime.Today.AddDays(7)).ToList()
}; };
return View(upcoming); return View(upcoming);

View File

@ -10,6 +10,11 @@ public class UpcomingEpisodesModel
public List<UpcomingEpisodeModel> Yesterday { get; set; } public List<UpcomingEpisodeModel> Yesterday { get; set; }
public List<UpcomingEpisodeModel> Today { get; set; } public List<UpcomingEpisodeModel> Today { get; set; }
public List<UpcomingEpisodeModel> Tomorrow { get; set; } public List<UpcomingEpisodeModel> Tomorrow { get; set; }
public List<UpcomingEpisodeModel> Week { get; set; } public List<UpcomingEpisodeModel> TwoDays { get; set; }
public List<UpcomingEpisodeModel> ThreeDays { get; set; }
public List<UpcomingEpisodeModel> FourDays { get; set; }
public List<UpcomingEpisodeModel> FiveDays { get; set; }
public List<UpcomingEpisodeModel> SixDays { get; set; }
public List<UpcomingEpisodeModel> Later { get; set; }
} }
} }

View File

@ -111,14 +111,109 @@
Html.RenderPartial("UpcomingEpisode", episode, new ViewDataDictionary { new KeyValuePair<string, object>("AltRow", true) }); Html.RenderPartial("UpcomingEpisode", episode, new ViewDataDictionary { new KeyValuePair<string, object>("AltRow", true) });
} }
} }
<tr class="title-row">
<td colspan="6">
@DateTime.Today.AddDays(2).DayOfWeek
</td>
</tr>
@for (int i = 0; i < Model.TwoDays.Count; i++)
{
var episode = Model.TwoDays[i];
if (i % 2 == 0)
{
Html.RenderPartial("UpcomingEpisode", episode);
}
else
{
Html.RenderPartial("UpcomingEpisode", episode, new ViewDataDictionary { new KeyValuePair<string, object>("AltRow", true) });
}
}
<tr class="title-row">
<td colspan="6">
@DateTime.Today.AddDays(3).DayOfWeek
</td>
</tr>
@for (int i = 0; i < Model.ThreeDays.Count; i++)
{
var episode = Model.ThreeDays[i];
if (i % 2 == 0)
{
Html.RenderPartial("UpcomingEpisode", episode);
}
else
{
Html.RenderPartial("UpcomingEpisode", episode, new ViewDataDictionary { new KeyValuePair<string, object>("AltRow", true) });
}
}
<tr class="title-row">
<td colspan="6">
@DateTime.Today.AddDays(4).DayOfWeek
</td>
</tr>
@for (int i = 0; i < Model.FourDays.Count; i++)
{
var episode = Model.FourDays[i];
if (i % 2 == 0)
{
Html.RenderPartial("UpcomingEpisode", episode);
}
else
{
Html.RenderPartial("UpcomingEpisode", episode, new ViewDataDictionary { new KeyValuePair<string, object>("AltRow", true) });
}
}
<tr class="title-row">
<td colspan="6">
@DateTime.Today.AddDays(5).DayOfWeek
</td>
</tr>
@for (int i = 0; i < Model.FiveDays.Count; i++)
{
var episode = Model.FiveDays[i];
if (i % 2 == 0)
{
Html.RenderPartial("UpcomingEpisode", episode);
}
else
{
Html.RenderPartial("UpcomingEpisode", episode, new ViewDataDictionary { new KeyValuePair<string, object>("AltRow", true) });
}
}
<tr class="title-row">
<td colspan="6">
@DateTime.Today.AddDays(6).DayOfWeek
</td>
</tr>
@for (int i = 0; i < Model.SixDays.Count; i++)
{
var episode = Model.SixDays[i];
if (i % 2 == 0)
{
Html.RenderPartial("UpcomingEpisode", episode);
}
else
{
Html.RenderPartial("UpcomingEpisode", episode, new ViewDataDictionary { new KeyValuePair<string, object>("AltRow", true) });
}
}
<tr class="title-row"> <tr class="title-row">
<td colspan="6"> <td colspan="6">
Later Later
</td> </td>
</tr> </tr>
@for (int i = 0; i < Model.Week.Count; i++) @for (int i = 0; i < Model.Later.Count; i++)
{ {
var episode = Model.Week[i]; var episode = Model.Later[i];
if (i % 2 == 0) if (i % 2 == 0)
{ {