Added UpdateSeries to SeriesProvider.

Edit now works for Series, AJAX save.
Fixed Adding new series to use the DefaultQualityProfile as the QualityProfileId value.
This commit is contained in:
markus101 2011-02-17 18:50:40 -08:00
parent d3b7d199ab
commit dbca3a1974
6 changed files with 83 additions and 79 deletions

View File

@ -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);
} }
} }

View File

@ -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

View File

@ -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");
}
} }
} }

View File

@ -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>

View File

@ -2,73 +2,45 @@
<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">
<%: Html.LabelFor(model => model.SeriesId) %>
</div>
<div class="editor-field">
<%: Html.TextBoxFor(model => model.SeriesId) %>
<%: Html.ValidationMessageFor(model => model.SeriesId) %>
</div>
<div class="editor-label">
<%: Html.LabelFor(model => model.Title) %>
</div>
<div class="editor-field">
<%: Html.TextBoxFor(model => model.Title) %>
<%: Html.ValidationMessageFor(model => model.Title) %>
</div>
<div class="editor-label">
<%: Html.LabelFor(model => model.CleanTitle) %>
</div>
<div class="editor-field">
<%: Html.TextBoxFor(model => model.CleanTitle) %>
<%: Html.ValidationMessageFor(model => model.CleanTitle) %>
</div>
<div class="editor-label">
<%: Html.LabelFor(model => model.Status) %>
</div>
<div class="editor-field">
<%: 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.ValidationMessageFor(model => model.Overview) %>
</div>
<div class="editor-label">
<%: Html.LabelFor(model => model.AirTimes) %>
</div>
<div class="editor-field">
<%: 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.ValidationMessageFor(model => model.Language) %>
</div>
<div class="editor-label"> <div class="editor-label">
<%: Html.LabelFor(model => model.Path) %> <%: Html.LabelFor(model => model.Path) %>
@ -82,29 +54,42 @@
<%: Html.LabelFor(model => model.Monitored) %> <%: Html.LabelFor(model => model.Monitored) %>
</div> </div>
<div class="editor-field"> <div class="editor-field">
<%: Html.TextBoxFor(model => model.Monitored) %> <%: Html.CheckBoxFor(model => model.Monitored) %>
<%: Html.ValidationMessageFor(model => model.Monitored) %> <%: Html.ValidationMessageFor(model => model.Monitored) %>
</div> </div>
<%--<div class="editor-label"> <div class="editor-label">
<%: Html.LabelFor(model => model.ProfileId) %> <%: Html.LabelFor(model => model.QualityProfileId) %>
</div> </div>
<div class="editor-field"> <div class="editor-field">
<%: Html.TextBoxFor(model => model.ProfileId) %> <%: Html.DropDownListFor(model => model.QualityProfileId, (SelectList)ViewData["SelectList"])%>
<%: Html.ValidationMessageFor(model => model.ProfileId) %> <%: Html.ValidationMessageFor(model => model.QualityProfileId) %>
</div>--%> </div>
<div class="hidden" style="display:none;">
<%: Html.TextBoxFor(model => model.SeriesId) %>
<%: Html.TextBoxFor(model => model.Title) %>
<%: Html.TextBoxFor(model => model.CleanTitle) %>
<%: Html.TextBoxFor(model => model.Status) %>
<%: Html.TextBoxFor(model => model.Overview) %>
<%: Html.TextBoxFor(model => model.AirsDayOfWeek) %>
<%: Html.TextBoxFor(model => model.AirTimes) %>
<%: Html.TextBoxFor(model => model.Language) %>
</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">

View File

@ -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(); %>