2010-09-23 03:19:47 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
2010-10-30 02:46:32 +00:00
|
|
|
|
using System.Threading;
|
2010-09-23 03:19:47 +00:00
|
|
|
|
using System.Web;
|
|
|
|
|
using System.Web.Mvc;
|
2010-09-28 04:25:41 +00:00
|
|
|
|
using NzbDrone.Core.Providers;
|
2010-10-30 02:46:32 +00:00
|
|
|
|
using NzbDrone.Core.Repository;
|
|
|
|
|
using NzbDrone.Web.Models;
|
|
|
|
|
using Telerik.Web.Mvc;
|
2010-09-23 03:19:47 +00:00
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Web.Controllers
|
|
|
|
|
{
|
2010-10-08 03:35:04 +00:00
|
|
|
|
[HandleError]
|
2010-09-23 03:19:47 +00:00
|
|
|
|
public class SeriesController : Controller
|
|
|
|
|
{
|
2010-09-28 04:25:41 +00:00
|
|
|
|
private readonly ISeriesProvider _seriesProvider;
|
2010-10-05 06:21:18 +00:00
|
|
|
|
private readonly IEpisodeProvider _episodeProvider;
|
2010-10-17 17:22:48 +00:00
|
|
|
|
private readonly ISyncProvider _syncProvider;
|
2011-01-31 01:30:59 +00:00
|
|
|
|
private readonly IRssSyncProvider _rssSyncProvider;
|
2011-02-18 02:50:40 +00:00
|
|
|
|
private readonly IQualityProvider _qualityProvider;
|
2010-09-23 03:19:47 +00:00
|
|
|
|
//
|
|
|
|
|
// GET: /Series/
|
|
|
|
|
|
2011-02-18 02:50:40 +00:00
|
|
|
|
public SeriesController(ISyncProvider syncProvider, ISeriesProvider seriesProvider, IEpisodeProvider episodeProvider, IRssSyncProvider rssSyncProvider, IQualityProvider qualityProvider)
|
2010-09-23 03:19:47 +00:00
|
|
|
|
{
|
2010-09-28 04:25:41 +00:00
|
|
|
|
_seriesProvider = seriesProvider;
|
2010-10-05 06:21:18 +00:00
|
|
|
|
_episodeProvider = episodeProvider;
|
2010-10-17 17:22:48 +00:00
|
|
|
|
_syncProvider = syncProvider;
|
2011-01-31 01:30:59 +00:00
|
|
|
|
_rssSyncProvider = rssSyncProvider;
|
2011-02-18 02:50:40 +00:00
|
|
|
|
_qualityProvider = qualityProvider;
|
2010-09-23 03:19:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ActionResult Index()
|
|
|
|
|
{
|
2010-10-17 17:22:48 +00:00
|
|
|
|
ViewData.Model = _seriesProvider.GetAllSeries().ToList();
|
2010-09-23 03:19:47 +00:00
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ActionResult Sync()
|
|
|
|
|
{
|
2010-10-17 17:22:48 +00:00
|
|
|
|
_syncProvider.BeginSyncUnmappedFolders();
|
2010-09-23 03:19:47 +00:00
|
|
|
|
return RedirectToAction("Index");
|
|
|
|
|
}
|
|
|
|
|
|
2011-01-31 01:30:59 +00:00
|
|
|
|
public ActionResult RssSync()
|
|
|
|
|
{
|
|
|
|
|
_rssSyncProvider.Begin();
|
|
|
|
|
return RedirectToAction("Index");
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-02 19:01:43 +00:00
|
|
|
|
public ActionResult UnMapped()
|
|
|
|
|
{
|
2011-02-04 00:48:09 +00:00
|
|
|
|
return View(_seriesProvider.GetUnmappedFolders().Select(c => new MappingModel() { Id = 1, Path = c.Value }).ToList());
|
2010-10-02 19:01:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-10-05 06:21:18 +00:00
|
|
|
|
public ActionResult LoadEpisodes(int seriesId)
|
2010-09-23 03:19:47 +00:00
|
|
|
|
{
|
2010-10-17 17:22:48 +00:00
|
|
|
|
_episodeProvider.RefreshEpisodeInfo(seriesId);
|
2010-10-05 06:21:18 +00:00
|
|
|
|
return RedirectToAction("Details", new
|
2010-09-23 03:19:47 +00:00
|
|
|
|
{
|
2010-10-05 06:21:18 +00:00
|
|
|
|
seriesId = seriesId
|
|
|
|
|
});
|
2010-09-23 03:19:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-10-30 02:46:32 +00:00
|
|
|
|
[GridAction]
|
|
|
|
|
public ActionResult _AjaxSeasonGrid(int seasonId)
|
2010-10-08 05:04:25 +00:00
|
|
|
|
{
|
2010-10-30 02:46:32 +00:00
|
|
|
|
var episodes = _episodeProvider.GetEpisodeBySeason(seasonId).Select(c => new EpisodeModel()
|
|
|
|
|
{
|
|
|
|
|
EpisodeId = c.EpisodeId,
|
|
|
|
|
EpisodeNumber = c.EpisodeNumber,
|
|
|
|
|
SeasonNumber = c.SeasonNumber,
|
|
|
|
|
Title = c.Title,
|
|
|
|
|
Overview = c.Overview,
|
|
|
|
|
AirDate = c.AirDate
|
|
|
|
|
});
|
|
|
|
|
return View(new GridModel(episodes));
|
2010-10-08 05:04:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-10-30 02:46:32 +00:00
|
|
|
|
[GridAction]
|
|
|
|
|
public ActionResult _CustomBinding(GridCommand command, int seasonId)
|
2010-10-08 05:50:01 +00:00
|
|
|
|
{
|
2010-10-30 02:46:32 +00:00
|
|
|
|
IEnumerable<Episode> data = GetData(command);
|
|
|
|
|
return View(new GridModel
|
|
|
|
|
{
|
|
|
|
|
Data = data,
|
|
|
|
|
Total = data.Count()
|
|
|
|
|
});
|
2010-10-08 05:50:01 +00:00
|
|
|
|
}
|
2010-10-30 02:46:32 +00:00
|
|
|
|
private IEnumerable<Episode> GetData(GridCommand command)
|
2010-10-08 05:50:01 +00:00
|
|
|
|
{
|
2010-10-30 02:46:32 +00:00
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
/*
|
|
|
|
|
IQueryable<Episode> data = .Orders;
|
|
|
|
|
//Apply filtering
|
|
|
|
|
if (command.FilterDescriptors.Any())
|
|
|
|
|
{
|
|
|
|
|
data = data.Where(ExpressionBuilder.Expression<Order>(command.FilterDescriptors));
|
|
|
|
|
}
|
|
|
|
|
// Apply sorting
|
|
|
|
|
foreach (SortDescriptor sortDescriptor in command.SortDescriptors)
|
|
|
|
|
{
|
|
|
|
|
if (sortDescriptor.SortDirection == ListSortDirection.Ascending)
|
|
|
|
|
{
|
|
|
|
|
switch (sortDescriptor.Member)
|
|
|
|
|
{
|
|
|
|
|
case "OrderID":
|
|
|
|
|
data = data.OrderBy(ExpressionBuilder.Expression<Order, int>(sortDescriptor.Member));
|
|
|
|
|
break;
|
|
|
|
|
case "Customer.ContactName":
|
|
|
|
|
data = data.OrderBy(order => order.Customer.ContactName);
|
|
|
|
|
break;
|
|
|
|
|
case "ShipAddress":
|
|
|
|
|
data = data.OrderBy(order => order.ShipAddress);
|
|
|
|
|
break;
|
|
|
|
|
case "OrderDate":
|
|
|
|
|
data = data.OrderBy(order => order.OrderDate);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
switch (sortDescriptor.Member)
|
|
|
|
|
{
|
|
|
|
|
case "OrderID":
|
|
|
|
|
data = data.OrderByDescending(order => order.OrderID);
|
|
|
|
|
break;
|
|
|
|
|
case "Customer.ContactName":
|
|
|
|
|
data = data.OrderByDescending(order => order.Customer.ContactName);
|
|
|
|
|
break;
|
|
|
|
|
case "ShipAddress":
|
|
|
|
|
data = data.OrderByDescending(order => order.ShipAddress);
|
|
|
|
|
break;
|
|
|
|
|
case "OrderDate":
|
|
|
|
|
data = data.OrderByDescending(order => order.OrderDate);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
count = data.Count();
|
|
|
|
|
// ... and paging
|
|
|
|
|
if (command.PageSize > 0)
|
2010-10-08 05:50:01 +00:00
|
|
|
|
{
|
2010-10-30 02:46:32 +00:00
|
|
|
|
data = data.Skip((command.Page - 1) * command.PageSize);
|
2010-10-08 05:50:01 +00:00
|
|
|
|
}
|
2010-10-30 02:46:32 +00:00
|
|
|
|
data = data.Take(command.PageSize);
|
|
|
|
|
return data;*/
|
2010-10-08 05:50:01 +00:00
|
|
|
|
}
|
2010-10-17 17:22:48 +00:00
|
|
|
|
|
2010-09-23 03:19:47 +00:00
|
|
|
|
//
|
2010-10-05 06:21:18 +00:00
|
|
|
|
// GET: /Series/Details/5
|
2010-09-23 03:19:47 +00:00
|
|
|
|
|
2011-02-04 00:48:09 +00:00
|
|
|
|
[AcceptVerbs(HttpVerbs.Post)]
|
|
|
|
|
[GridAction]
|
|
|
|
|
public ActionResult _SaveAjaxEditing(string id)
|
|
|
|
|
{
|
|
|
|
|
return RedirectToAction("UnMapped");
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-05 06:21:18 +00:00
|
|
|
|
public ActionResult Details(int seriesId)
|
2010-09-23 03:19:47 +00:00
|
|
|
|
{
|
2011-02-17 17:45:02 +00:00
|
|
|
|
var series = _seriesProvider.GetSeries(seriesId);
|
|
|
|
|
return View(series);
|
2010-09-23 03:19:47 +00:00
|
|
|
|
}
|
2011-02-18 02:50:40 +00:00
|
|
|
|
|
|
|
|
|
public ActionResult Edit(int seriesId)
|
|
|
|
|
{
|
|
|
|
|
var profiles = _qualityProvider.GetAllProfiles();
|
|
|
|
|
ViewData["SelectList"] = new SelectList(profiles, "QualityProfileId", "Name");
|
|
|
|
|
|
|
|
|
|
var series = _seriesProvider.GetSeries(seriesId);
|
|
|
|
|
return View(series);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public ActionResult Edit(Series series)
|
|
|
|
|
{
|
|
|
|
|
//Need to add seriesProvider.Update
|
|
|
|
|
_seriesProvider.UpdateSeries(series);
|
|
|
|
|
return Content("Series Updated Successfully");
|
|
|
|
|
}
|
2010-09-23 03:19:47 +00:00
|
|
|
|
}
|
|
|
|
|
}
|