Added UpdateSeries to SeriesProvider.

Edit now works for Series, AJAX save.
Fixed Adding new series to use the DefaultQualityProfile as the QualityProfileId value.
pull/4/head
markus101 14 years ago
parent d3b7d199ab
commit dbca3a1974

@ -24,5 +24,6 @@ namespace NzbDrone.Core.Providers
Dictionary<Guid, String> GetUnmappedFolders(); Dictionary<Guid, String> GetUnmappedFolders();
Series FindSeries(string cleanTitle); Series FindSeries(string cleanTitle);
bool QualityWanted(int seriesId, QualityTypes quality); bool QualityWanted(int seriesId, QualityTypes quality);
void UpdateSeries(Series series);
} }
} }

@ -108,7 +108,7 @@ namespace NzbDrone.Core.Providers
repoSeries.Path = path; repoSeries.Path = path;
repoSeries.CleanTitle = Parser.NormalizeTitle(series.SeriesName); repoSeries.CleanTitle = Parser.NormalizeTitle(series.SeriesName);
repoSeries.Monitored = true; //New shows should be monitored repoSeries.Monitored = true; //New shows should be monitored
repoSeries.QualityProfileId = Convert.ToInt32(_config.GetValue("Quality", 1, true)); repoSeries.QualityProfileId = Convert.ToInt32(_config.GetValue("DefaultQualityProfile", "1", true));
_sonioRepo.Add(repoSeries); _sonioRepo.Add(repoSeries);
} }
@ -117,6 +117,11 @@ namespace NzbDrone.Core.Providers
return _sonioRepo.Single<Series>(s => s.CleanTitle == cleanTitle); return _sonioRepo.Single<Series>(s => s.CleanTitle == cleanTitle);
} }
public void UpdateSeries(Series series)
{
_sonioRepo.Update(series);
}
#endregion #endregion
#region Static Helpers #region Static Helpers

@ -18,15 +18,17 @@ namespace NzbDrone.Web.Controllers
private readonly IEpisodeProvider _episodeProvider; private readonly IEpisodeProvider _episodeProvider;
private readonly ISyncProvider _syncProvider; private readonly ISyncProvider _syncProvider;
private readonly IRssSyncProvider _rssSyncProvider; private readonly IRssSyncProvider _rssSyncProvider;
private readonly IQualityProvider _qualityProvider;
// //
// GET: /Series/ // GET: /Series/
public SeriesController(ISyncProvider syncProvider, ISeriesProvider seriesProvider, IEpisodeProvider episodeProvider, IRssSyncProvider rssSyncProvider) public SeriesController(ISyncProvider syncProvider, ISeriesProvider seriesProvider, IEpisodeProvider episodeProvider, IRssSyncProvider rssSyncProvider, IQualityProvider qualityProvider)
{ {
_seriesProvider = seriesProvider; _seriesProvider = seriesProvider;
_episodeProvider = episodeProvider; _episodeProvider = episodeProvider;
_syncProvider = syncProvider; _syncProvider = syncProvider;
_rssSyncProvider = rssSyncProvider; _rssSyncProvider = rssSyncProvider;
_qualityProvider = qualityProvider;
} }
public ActionResult Index() public ActionResult Index()
@ -52,12 +54,6 @@ namespace NzbDrone.Web.Controllers
return View(_seriesProvider.GetUnmappedFolders().Select(c => new MappingModel() { Id = 1, Path = c.Value }).ToList()); return View(_seriesProvider.GetUnmappedFolders().Select(c => new MappingModel() { Id = 1, Path = c.Value }).ToList());
} }
public ActionResult Edit(int seriesId)
{
var series = _seriesProvider.GetSeries(seriesId);
return View(series);
}
public ActionResult LoadEpisodes(int seriesId) public ActionResult LoadEpisodes(int seriesId)
{ {
_episodeProvider.RefreshEpisodeInfo(seriesId); _episodeProvider.RefreshEpisodeInfo(seriesId);
@ -168,5 +164,22 @@ namespace NzbDrone.Web.Controllers
var series = _seriesProvider.GetSeries(seriesId); var series = _seriesProvider.GetSeries(seriesId);
return View(series); return View(series);
} }
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");
}
} }
} }

@ -88,7 +88,7 @@ Html.Telerik().Grid(specialSeasons.Episodes).Name("seasons_specials")
} }
%> %>
<p> <p>
<%-- <%: Html.ActionLink("Edit", "Edit", new { /* id=Model.PrimaryKey */ }) %> |--%> <%: Html.ActionLink("Edit", "Edit", new {seriesId = Model.SeriesId}) %> |
<%: Html.ActionLink("Back to Series", "Index") %> <%: Html.ActionLink("Back to Series", "Index") %>
</p> </p>
</asp:Content> </asp:Content>

@ -2,109 +2,94 @@
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server"> <asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
Edit Edit
<script type="text/javascript">
$(document).ready(function () {
var options = {
target: '#result',
beforeSubmit: showRequest,
success: showResponse,
type: 'post',
resetForm: false
};
$('#form').ajaxForm(options);
$('#save_button').attr('disabled', '');
});
function showRequest(formData, jqForm, options) {
$("#result").empty().html('Saving Series...');
$("#form :input").attr("disabled", true);
}
function showResponse(responseText, statusText, xhr, $form) {
$("#result").empty().html(responseText);
$("#form :input").attr("disabled", false);
}
</script>
</asp:Content> </asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"> <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<h2>Edit</h2> <h2><%: Html.DisplayTextFor(model => model.Title) %></h2>
<% using (Html.BeginForm()) {%> <% Html.EnableClientValidation(); %>
<%: Html.ValidationSummary(true) %> <% using (Html.BeginForm("Edit", "Series", FormMethod.Post, new { id = "form", name = "form" }))
{ %>
<fieldset> <fieldset>
<legend>Fields</legend> <legend>Edit</legend>
<div class="editor-label"> <div class="editor-label">
<%: Html.LabelFor(model => model.SeriesId) %> <%: Html.LabelFor(model => model.Path) %>
</div> </div>
<div class="editor-field"> <div class="editor-field">
<%: Html.TextBoxFor(model => model.SeriesId) %> <%: Html.TextBoxFor(model => model.Path) %>
<%: Html.ValidationMessageFor(model => model.SeriesId) %> <%: Html.ValidationMessageFor(model => model.Path) %>
</div> </div>
<div class="editor-label"> <div class="editor-label">
<%: Html.LabelFor(model => model.Title) %> <%: Html.LabelFor(model => model.Monitored) %>
</div> </div>
<div class="editor-field"> <div class="editor-field">
<%: Html.TextBoxFor(model => model.Title) %> <%: Html.CheckBoxFor(model => model.Monitored) %>
<%: Html.ValidationMessageFor(model => model.Title) %> <%: Html.ValidationMessageFor(model => model.Monitored) %>
</div> </div>
<div class="editor-label"> <div class="editor-label">
<%: Html.LabelFor(model => model.CleanTitle) %> <%: Html.LabelFor(model => model.QualityProfileId) %>
</div> </div>
<div class="editor-field"> <div class="editor-field">
<%: Html.TextBoxFor(model => model.CleanTitle) %> <%: Html.DropDownListFor(model => model.QualityProfileId, (SelectList)ViewData["SelectList"])%>
<%: Html.ValidationMessageFor(model => model.CleanTitle) %> <%: Html.ValidationMessageFor(model => model.QualityProfileId) %>
</div> </div>
<div class="editor-label"> <div class="hidden" style="display:none;">
<%: Html.LabelFor(model => model.Status) %> <%: Html.TextBoxFor(model => model.SeriesId) %>
</div> <%: Html.TextBoxFor(model => model.Title) %>
<div class="editor-field"> <%: Html.TextBoxFor(model => model.CleanTitle) %>
<%: Html.TextBoxFor(model => model.Status) %> <%: Html.TextBoxFor(model => model.Status) %>
<%: Html.ValidationMessageFor(model => model.Status) %>
</div>
<div class="editor-label">
<%: Html.LabelFor(model => model.Overview) %>
</div>
<div class="editor-field">
<%: Html.TextBoxFor(model => model.Overview) %> <%: Html.TextBoxFor(model => model.Overview) %>
<%: Html.ValidationMessageFor(model => model.Overview) %> <%: Html.TextBoxFor(model => model.AirsDayOfWeek) %>
</div>
<div class="editor-label">
<%: Html.LabelFor(model => model.AirTimes) %>
</div>
<div class="editor-field">
<%: Html.TextBoxFor(model => model.AirTimes) %> <%: Html.TextBoxFor(model => model.AirTimes) %>
<%: Html.ValidationMessageFor(model => model.AirTimes) %>
</div>
<div class="editor-label">
<%: Html.LabelFor(model => model.Language) %>
</div>
<div class="editor-field">
<%: Html.TextBoxFor(model => model.Language) %> <%: Html.TextBoxFor(model => model.Language) %>
<%: Html.ValidationMessageFor(model => model.Language) %>
</div>
<div class="editor-label">
<%: Html.LabelFor(model => model.Path) %>
</div>
<div class="editor-field">
<%: Html.TextBoxFor(model => model.Path) %>
<%: Html.ValidationMessageFor(model => model.Path) %>
</div>
<div class="editor-label">
<%: Html.LabelFor(model => model.Monitored) %>
</div>
<div class="editor-field">
<%: Html.TextBoxFor(model => model.Monitored) %>
<%: Html.ValidationMessageFor(model => model.Monitored) %>
</div> </div>
<%--<div class="editor-label">
<%: Html.LabelFor(model => model.ProfileId) %>
</div>
<div class="editor-field">
<%: Html.TextBoxFor(model => model.ProfileId) %>
<%: Html.ValidationMessageFor(model => model.ProfileId) %>
</div>--%>
<p> <p>
<input type="submit" value="Save" /> <input type="submit" id="save_button" value="Save" disabled="disabled" />
</p> </p>
</fieldset> </fieldset>
<% } %> <% } %>
<div> <div>
<%: Html.ActionLink("Back to Show", "Details", new { seriesId = Model.SeriesId }) %> |
<%: Html.ActionLink("Back to List", "Index") %> <%: Html.ActionLink("Back to List", "Index") %>
</div> </div>
<div id="result"></div>
</asp:Content> </asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="headerContent" runat="server"> <asp:Content ID="Content3" ContentPlaceHolderID="headerContent" runat="server">

@ -22,7 +22,7 @@
$("#result").empty().html(responseText); $("#result").empty().html(responseText);
$("#form :input").attr("disabled", false); $("#form :input").attr("disabled", false);
} }
</script> </script>
<% Html.EnableClientValidation(); %> <% Html.EnableClientValidation(); %>

Loading…
Cancel
Save