2011-04-27 05:47:29 +03:00
|
|
|
using System;
|
2011-06-14 18:14:33 +03:00
|
|
|
using System.Collections.Generic;
|
2011-04-27 05:47:29 +03:00
|
|
|
using System.Linq;
|
2011-03-23 09:06:22 +02:00
|
|
|
using System.Web.Mvc;
|
2011-09-29 03:20:29 +03:00
|
|
|
using NzbDrone.Core;
|
2011-03-23 09:06:22 +02:00
|
|
|
using NzbDrone.Core.Providers;
|
|
|
|
using NzbDrone.Web.Models;
|
|
|
|
using Telerik.Web.Mvc;
|
|
|
|
|
|
|
|
namespace NzbDrone.Web.Controllers
|
|
|
|
{
|
|
|
|
public class UpcomingController : Controller
|
|
|
|
{
|
2011-04-10 05:44:01 +03:00
|
|
|
private readonly UpcomingEpisodesProvider _upcomingEpisodesProvider;
|
2011-03-23 09:06:22 +02:00
|
|
|
|
2011-06-22 04:10:31 +03:00
|
|
|
public UpcomingController(UpcomingEpisodesProvider upcomingEpisodesProvider)
|
2011-03-23 09:06:22 +02:00
|
|
|
{
|
|
|
|
_upcomingEpisodesProvider = upcomingEpisodesProvider;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// GET: /Upcoming/
|
|
|
|
|
|
|
|
public ActionResult Index()
|
|
|
|
{
|
|
|
|
return View();
|
|
|
|
}
|
|
|
|
|
|
|
|
[GridAction]
|
|
|
|
public ActionResult _AjaxBindingYesterday()
|
|
|
|
{
|
2011-06-20 06:08:09 +03:00
|
|
|
var upcoming = _upcomingEpisodesProvider.Yesterday().Select(u => new UpcomingEpisodeModel
|
2011-06-14 18:14:33 +03:00
|
|
|
{
|
2011-06-20 06:08:09 +03:00
|
|
|
SeriesId = u.Series.SeriesId,
|
|
|
|
EpisodeId = u.EpisodeId,
|
2011-08-31 03:15:22 +03:00
|
|
|
SeriesTitle = u.Series.Title,
|
2011-06-20 06:08:09 +03:00
|
|
|
SeasonNumber = u.SeasonNumber,
|
|
|
|
EpisodeNumber = u.EpisodeNumber,
|
|
|
|
Title = u.Title,
|
|
|
|
Overview = u.Overview,
|
2011-10-11 04:11:22 +03:00
|
|
|
AirDateTime = GetDateTime(u.AirDate.Value, u.Series.AirTimes),
|
2011-09-29 03:20:29 +03:00
|
|
|
AirDate = u.AirDate.Value.ToBestDateString(),
|
2011-10-11 04:11:22 +03:00
|
|
|
AirTime = String.IsNullOrEmpty(u.Series.AirTimes) ? "?" : Convert.ToDateTime(u.Series.AirTimes).ToShortTimeString(),
|
2011-09-29 03:20:29 +03:00
|
|
|
Status = u.Status.ToString()
|
2011-06-20 06:08:09 +03:00
|
|
|
});
|
2011-04-10 05:44:01 +03:00
|
|
|
|
2011-03-23 09:06:22 +02:00
|
|
|
return View(new GridModel(upcoming));
|
|
|
|
}
|
|
|
|
|
|
|
|
[GridAction]
|
|
|
|
public ActionResult _AjaxBindingToday()
|
|
|
|
{
|
2011-06-20 06:08:09 +03:00
|
|
|
var upcoming = _upcomingEpisodesProvider.Today().Select(u => new UpcomingEpisodeModel
|
2011-06-14 18:14:33 +03:00
|
|
|
{
|
2011-06-20 06:08:09 +03:00
|
|
|
SeriesId = u.Series.SeriesId,
|
|
|
|
EpisodeId = u.EpisodeId,
|
2011-08-31 03:15:22 +03:00
|
|
|
SeriesTitle = u.Series.Title,
|
2011-06-20 06:08:09 +03:00
|
|
|
SeasonNumber = u.SeasonNumber,
|
|
|
|
EpisodeNumber = u.EpisodeNumber,
|
|
|
|
Title = u.Title,
|
|
|
|
Overview = u.Overview,
|
2011-10-11 04:11:22 +03:00
|
|
|
AirDateTime = GetDateTime(u.AirDate.Value, u.Series.AirTimes),
|
2011-09-29 03:20:29 +03:00
|
|
|
AirDate = u.AirDate.Value.ToBestDateString(),
|
2011-10-11 04:11:22 +03:00
|
|
|
AirTime = String.IsNullOrEmpty(u.Series.AirTimes) ? "?" : Convert.ToDateTime(u.Series.AirTimes).ToShortTimeString(),
|
2011-09-29 03:20:29 +03:00
|
|
|
Status = u.Status.ToString()
|
2011-06-20 06:08:09 +03:00
|
|
|
});
|
2011-03-23 09:06:22 +02:00
|
|
|
|
|
|
|
return View(new GridModel(upcoming));
|
|
|
|
}
|
|
|
|
|
2011-04-28 02:51:38 +03:00
|
|
|
[GridAction]
|
|
|
|
public ActionResult _AjaxBindingTomorrow()
|
|
|
|
{
|
2011-06-20 06:08:09 +03:00
|
|
|
var upcoming = _upcomingEpisodesProvider.Tomorrow().Select(u => new UpcomingEpisodeModel
|
2011-04-28 02:51:38 +03:00
|
|
|
{
|
2011-06-20 06:08:09 +03:00
|
|
|
SeriesId = u.Series.SeriesId,
|
|
|
|
EpisodeId = u.EpisodeId,
|
2011-08-31 03:15:22 +03:00
|
|
|
SeriesTitle = u.Series.Title,
|
2011-06-20 06:08:09 +03:00
|
|
|
SeasonNumber = u.SeasonNumber,
|
|
|
|
EpisodeNumber = u.EpisodeNumber,
|
|
|
|
Title = u.Title,
|
|
|
|
Overview = u.Overview,
|
2011-10-11 04:11:22 +03:00
|
|
|
AirDateTime = GetDateTime(u.AirDate.Value, u.Series.AirTimes),
|
2011-09-29 03:20:29 +03:00
|
|
|
AirDate = u.AirDate.Value.ToBestDateString(),
|
2011-10-11 04:11:22 +03:00
|
|
|
AirTime = String.IsNullOrEmpty(u.Series.AirTimes) ? "?" : Convert.ToDateTime(u.Series.AirTimes).ToShortTimeString(),
|
2011-09-29 03:20:29 +03:00
|
|
|
Status = u.Status.ToString()
|
2011-06-20 06:08:09 +03:00
|
|
|
});
|
2011-04-28 02:51:38 +03:00
|
|
|
|
|
|
|
return View(new GridModel(upcoming));
|
|
|
|
}
|
|
|
|
|
2011-03-23 09:06:22 +02:00
|
|
|
[GridAction]
|
|
|
|
public ActionResult _AjaxBindingWeek()
|
|
|
|
{
|
2011-06-20 06:08:09 +03:00
|
|
|
var upcoming = _upcomingEpisodesProvider.Week().Select(u => new UpcomingEpisodeModel
|
2011-06-14 18:14:33 +03:00
|
|
|
{
|
2011-06-20 06:08:09 +03:00
|
|
|
SeriesId = u.Series.SeriesId,
|
|
|
|
EpisodeId = u.EpisodeId,
|
2011-08-31 03:15:22 +03:00
|
|
|
SeriesTitle = u.Series.Title,
|
2011-06-20 06:08:09 +03:00
|
|
|
SeasonNumber = u.SeasonNumber,
|
|
|
|
EpisodeNumber = u.EpisodeNumber,
|
|
|
|
Title = u.Title,
|
|
|
|
Overview = u.Overview,
|
2011-10-11 04:11:22 +03:00
|
|
|
AirDateTime = GetDateTime(u.AirDate.Value, u.Series.AirTimes),
|
2011-09-29 03:20:29 +03:00
|
|
|
AirDate = u.AirDate.Value.ToBestDateString(),
|
2011-10-11 04:11:22 +03:00
|
|
|
AirTime = String.IsNullOrEmpty(u.Series.AirTimes) ? "?" : Convert.ToDateTime(u.Series.AirTimes).ToShortTimeString(),
|
2011-09-29 03:20:29 +03:00
|
|
|
Status = u.Status.ToString()
|
2011-06-20 06:08:09 +03:00
|
|
|
});
|
2011-03-23 09:06:22 +02:00
|
|
|
|
|
|
|
return View(new GridModel(upcoming));
|
|
|
|
}
|
2011-10-11 04:11:22 +03:00
|
|
|
|
|
|
|
private DateTime GetDateTime(DateTime airDate, string airTime)
|
|
|
|
{
|
|
|
|
if (String.IsNullOrWhiteSpace(airTime))
|
|
|
|
return airDate;
|
|
|
|
|
|
|
|
return airDate.Add(Convert.ToDateTime(airTime).TimeOfDay);
|
|
|
|
}
|
2011-03-23 09:06:22 +02:00
|
|
|
}
|
2011-04-10 05:44:01 +03:00
|
|
|
}
|