2011-04-28 06:04:57 +00:00
|
|
|
|
using System;
|
2011-06-14 15:07:48 +00:00
|
|
|
|
using System.Collections.Generic;
|
2011-04-28 06:04:57 +00:00
|
|
|
|
using System.Linq;
|
2011-03-23 05:19:23 +00:00
|
|
|
|
using System.Web.Mvc;
|
2011-04-28 04:27:02 +00:00
|
|
|
|
using NzbDrone.Core.Model;
|
2011-03-23 05:19:23 +00:00
|
|
|
|
using NzbDrone.Core.Providers;
|
|
|
|
|
using NzbDrone.Web.Models;
|
|
|
|
|
using Telerik.Web.Mvc;
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Web.Controllers
|
|
|
|
|
{
|
|
|
|
|
public class HistoryController : Controller
|
|
|
|
|
{
|
2011-04-10 02:44:01 +00:00
|
|
|
|
private readonly HistoryProvider _historyProvider;
|
2011-06-17 06:59:13 +00:00
|
|
|
|
private readonly EpisodeProvider _episodeProvider;
|
2011-03-23 05:19:23 +00:00
|
|
|
|
|
2011-06-17 06:59:13 +00:00
|
|
|
|
public HistoryController(HistoryProvider historyProvider, EpisodeProvider episodeProvider)
|
2011-03-23 05:19:23 +00:00
|
|
|
|
{
|
|
|
|
|
_historyProvider = historyProvider;
|
2011-06-17 06:59:13 +00:00
|
|
|
|
_episodeProvider = episodeProvider;
|
2011-03-23 05:19:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// GET: /History/
|
|
|
|
|
|
|
|
|
|
public ActionResult Index()
|
|
|
|
|
{
|
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ActionResult Trim()
|
|
|
|
|
{
|
|
|
|
|
_historyProvider.Trim();
|
|
|
|
|
return RedirectToAction("Index");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ActionResult Purge()
|
|
|
|
|
{
|
|
|
|
|
_historyProvider.Purge();
|
|
|
|
|
return RedirectToAction("Index");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[GridAction]
|
|
|
|
|
public ActionResult _AjaxBinding()
|
|
|
|
|
{
|
2011-04-22 04:03:59 +00:00
|
|
|
|
|
|
|
|
|
//TODO: possible subsonic bug, IQuarible causes some issues so ToList() is called
|
2011-04-22 05:46:47 +00:00
|
|
|
|
//https://github.com/subsonic/SubSonic-3.0/issues/263
|
2011-05-19 03:58:42 +00:00
|
|
|
|
|
2011-06-14 15:07:48 +00:00
|
|
|
|
var historyDb = _historyProvider.AllItems().ToList();
|
|
|
|
|
|
|
|
|
|
var history = new List<HistoryModel>();
|
2011-06-17 06:59:13 +00:00
|
|
|
|
|
2011-06-14 15:07:48 +00:00
|
|
|
|
foreach (var item in historyDb)
|
|
|
|
|
{
|
2011-06-17 06:59:13 +00:00
|
|
|
|
var episode = _episodeProvider.GetEpisode(item.EpisodeId);
|
|
|
|
|
|
2011-06-14 15:07:48 +00:00
|
|
|
|
history.Add(new HistoryModel
|
|
|
|
|
{
|
|
|
|
|
HistoryId = item.HistoryId,
|
|
|
|
|
SeasonNumber = episode.SeasonNumber,
|
|
|
|
|
EpisodeNumber = episode.EpisodeNumber,
|
|
|
|
|
EpisodeTitle = episode.Title,
|
|
|
|
|
EpisodeOverview = episode.Overview,
|
2011-06-17 06:59:13 +00:00
|
|
|
|
SeriesTitle = episode.Series.Title,
|
2011-06-14 15:07:48 +00:00
|
|
|
|
NzbTitle = item.NzbTitle,
|
|
|
|
|
Quality = item.Quality.ToString(),
|
|
|
|
|
IsProper = item.IsProper,
|
|
|
|
|
Date = item.Date,
|
|
|
|
|
Indexer = item.Indexer
|
|
|
|
|
});
|
|
|
|
|
}
|
2011-03-23 05:19:23 +00:00
|
|
|
|
|
|
|
|
|
return View(new GridModel(history));
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-04-10 02:44:01 +00:00
|
|
|
|
}
|