diff --git a/NzbDrone.Web/Controllers/AddSeriesController.cs b/NzbDrone.Web/Controllers/AddSeriesController.cs index 0786baa92..6e0fabb76 100644 --- a/NzbDrone.Web/Controllers/AddSeriesController.cs +++ b/NzbDrone.Web/Controllers/AddSeriesController.cs @@ -69,7 +69,6 @@ public ActionResult Index() return View(); } - public ActionResult ExistingSeries() { var result = new ExistingSeriesModel(); @@ -81,7 +80,7 @@ public ActionResult ExistingSeries() unmappedList.AddRange(_rootFolderProvider.GetUnmappedFolders(folder.Path)); } - result.ExistingSeries = new List>(); + result.ExistingSeries = new List>(); foreach (var folder in unmappedList) { @@ -89,12 +88,14 @@ public ActionResult ExistingSeries() var tvdbResult = _tvDbProvider.SearchSeries(foldername).FirstOrDefault(); var title = String.Empty; + var seriesId = 0; if (tvdbResult != null) { title = tvdbResult.SeriesName; + seriesId = tvdbResult.Id; } - result.ExistingSeries.Add(new Tuple(folder, title)); + result.ExistingSeries.Add(new Tuple(folder, title, seriesId)); } var defaultQuality = Convert.ToInt32(_configProvider.DefaultQualityProfile); @@ -104,23 +105,21 @@ public ActionResult ExistingSeries() } [HttpPost] - public JsonResult AddNewSeries(string path, string seriesName, int qualityProfileId) + public JsonResult AddNewSeries(string path, string seriesName, int seriesId, int qualityProfileId) { path = Path.Combine(path, MediaFileProvider.CleanFilename(seriesName)); - return AddExistingSeries(path, seriesName, qualityProfileId); + return AddExistingSeries(path, seriesName, seriesId, qualityProfileId); } [HttpPost] - public JsonResult AddExistingSeries(string path, string seriesName, int qualityProfileId) + public JsonResult AddExistingSeries(string path, string seriesName, int seriesId, int qualityProfileId) { try { //Create the folder for the new series and then Add it _diskProvider.CreateDirectory(path); - var series = _tvDbProvider.SearchSeries(seriesName).Where(s => s.SeriesName == seriesName).Single(); - - _seriesProvider.AddSeries(path, series.Id, qualityProfileId); + _seriesProvider.AddSeries(path, seriesId, qualityProfileId); ScanNewSeries(); return Json(new NotificationResult() { Title = seriesName, Text = "Was added successfully" }); } diff --git a/NzbDrone.Web/Models/ExistingSeriesModel.cs b/NzbDrone.Web/Models/ExistingSeriesModel.cs index b6a391e42..dc7eddd5d 100644 --- a/NzbDrone.Web/Models/ExistingSeriesModel.cs +++ b/NzbDrone.Web/Models/ExistingSeriesModel.cs @@ -8,6 +8,6 @@ public class ExistingSeriesModel { public SelectList Quality { get; set; } - public List> ExistingSeries { get; set; } + public List> ExistingSeries { get; set; } } } \ No newline at end of file diff --git a/NzbDrone.Web/NzbDrone.Web.csproj b/NzbDrone.Web/NzbDrone.Web.csproj index 3841e86c4..b944d054e 100644 --- a/NzbDrone.Web/NzbDrone.Web.csproj +++ b/NzbDrone.Web/NzbDrone.Web.csproj @@ -683,9 +683,7 @@ - - diff --git a/NzbDrone.Web/Scripts/AutoComplete.js b/NzbDrone.Web/Scripts/AutoComplete.js index 42d30c94f..9aac1d28f 100644 --- a/NzbDrone.Web/Scripts/AutoComplete.js +++ b/NzbDrone.Web/Scripts/AutoComplete.js @@ -40,6 +40,7 @@ function bindSeriesAutoComplete(selector) { delay: 500, select: function (event, ui) { $(this).val(ui.item.Title); + $(this).siblings('.seriesId').val(ui.item.Id); return false; } }) diff --git a/NzbDrone.Web/Scripts/addSeries.js b/NzbDrone.Web/Scripts/addSeries.js index 358b78402..85d53ca07 100644 --- a/NzbDrone.Web/Scripts/addSeries.js +++ b/NzbDrone.Web/Scripts/addSeries.js @@ -23,6 +23,7 @@ $(".addExistingButton").live('click', function () { var root = $(this).parents(".existingSeries"); var title = $(this).siblings(".seriesLookup").val(); + var seriesId = $(this).siblings(".seriesId").val(); var qualityId = $(this).siblings(".qualitySelector").val(); var path = root.find(".seriesPathValue Label").text(); @@ -30,7 +31,7 @@ $(".addExistingButton").live('click', function () { $.ajax({ type: "POST", url: addSeriesUrl, - data: jQuery.param({ path: path, seriesName: title, qualityProfileId: qualityId }), + data: jQuery.param({ path: path, seriesName: title, seriesId: seriesId, qualityProfileId: qualityId }), error: function (req, status, error) { alert("Sorry! We could not add " + path + " at this time. " + error); }, @@ -79,13 +80,14 @@ function refreshRoot() { //AddNew $('#saveNewSeries').live('click', function () { var seriesTitle = $("#newSeriesLookup").val(); + var seriesId = $("#newSeriesId").val(); var qualityId = $("#qualityList").val(); var path = $('#newSeriesPath').val(); $.ajax({ type: "POST", url: addNewSeriesUrl, - data: jQuery.param({ path: path, seriesName: seriesTitle, qualityProfileId: qualityId }), + data: jQuery.param({ path: path, seriesName: seriesTitle, seriesId: seriesId, qualityProfileId: qualityId }), error: function (req, status, error) { alert("Sorry! We could not add " + path + " at this time. " + error); }, diff --git a/NzbDrone.Web/Views/AddSeries/AddNew.cshtml b/NzbDrone.Web/Views/AddSeries/AddNew.cshtml index af5e6e13b..c902a0396 100644 --- a/NzbDrone.Web/Views/AddSeries/AddNew.cshtml +++ b/NzbDrone.Web/Views/AddSeries/AddNew.cshtml @@ -4,8 +4,8 @@
+ @Html.Hidden("newSeriesId", 0, new { @class = "seriesId" })
- @**@ @Html.DropDownList("newSeriesPath", new SelectList((IList)ViewData["RootDirs"]), new { style = "width: 406px; margin-left: 0px;" }) @Html.DropDownList("qualityList", new SelectList((IList)ViewData["QualityList"], "QualityProfileId", "Name"), new { @class = "qualitySelector" })
} -@foreach (var series in Model.ExistingSeries) +@foreach (var series in Model.ExistingSeries) {
@@ -52,6 +52,7 @@ else
+ @Html.Hidden("seriesId", series.Item3, new { @class = "seriesId" }) @Html.DropDownList(Guid.NewGuid().ToString(), Model.Quality, new { @class = "qualitySelector" })