1
0
Fork 0
mirror of https://github.com/Sonarr/Sonarr synced 2024-12-27 18:28:19 +00:00
Sonarr/NzbDrone.Web/Controllers/HistoryController.cs

88 lines
3.1 KiB
C#
Raw Normal View History

2011-04-28 06:04:57 +00:00
using System;
using System.Collections.Generic;
2011-04-28 06:04:57 +00:00
using System.Linq;
using System.Web.Mvc;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Jobs;
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;
private readonly JobProvider _jobProvider;
public HistoryController(HistoryProvider historyProvider, JobProvider jobProvider)
{
_historyProvider = historyProvider;
_jobProvider = jobProvider;
}
//
// GET: /History/
public ActionResult Index()
{
return View();
}
public JsonResult Trim()
{
_historyProvider.Trim();
2011-08-22 01:00:12 +00:00
return Json(new NotificationResult() { Title = "Trimmed History items"});
}
public JsonResult Purge()
{
_historyProvider.Purge();
2011-08-22 01:00:12 +00:00
return Json(new NotificationResult() { Title = "History Cleared" });
}
[HttpPost]
public JsonResult Delete(int historyId)
{
//Delete the existing item from history
_historyProvider.Delete(historyId);
return Json(new NotificationResult() { Title = "History Item Deleted" });
}
[HttpPost]
public JsonResult Redownload(int historyId, int episodeId)
{
//Delete the existing item from history
_historyProvider.Delete(historyId);
//Queue a job to download the replacement episode
_jobProvider.QueueJob(typeof(EpisodeSearchJob), episodeId);
return Json(new NotificationResult() { Title = "Episode Redownload Started" });
}
[GridAction]
public ActionResult _AjaxBinding()
{
var history = _historyProvider.AllItemsWithRelationships().Select(h => new HistoryModel
{
HistoryId = h.HistoryId,
SeriesId = h.SeriesId,
SeasonNumber = h.Episode.SeasonNumber,
EpisodeNumber = h.Episode.EpisodeNumber,
EpisodeTitle = h.Episode.Title,
EpisodeOverview = h.Episode.Overview,
SeriesTitle = h.SeriesTitle,
NzbTitle = h.NzbTitle,
Quality = h.Quality.ToString(),
IsProper = h.IsProper,
Date = h.Date,
Indexer = h.Indexer,
EpisodeId = h.EpisodeId
});
return View(new GridModel(history));
}
}
2011-04-10 02:44:01 +00:00
}