Fixed settings saving notifications, duplicate keys.

This commit is contained in:
Mark McDowall 2011-08-05 20:05:41 -07:00
parent 963691b486
commit 127af22fe9
1 changed files with 30 additions and 28 deletions

View File

@ -32,7 +32,6 @@ namespace NzbDrone.Web.Controllers
private readonly DiskProvider _diskProvider; private readonly DiskProvider _diskProvider;
private readonly SeriesProvider _seriesProvider; private readonly SeriesProvider _seriesProvider;
private readonly ExternalNotificationProvider _externalNotificationProvider; private readonly ExternalNotificationProvider _externalNotificationProvider;
private readonly ProgressNotification _progressNotification;
public SettingsController(ConfigProvider configProvider, IndexerProvider indexerProvider, public SettingsController(ConfigProvider configProvider, IndexerProvider indexerProvider,
QualityProvider qualityProvider, RootDirProvider rootDirProvider, QualityProvider qualityProvider, RootDirProvider rootDirProvider,
@ -49,8 +48,6 @@ namespace NzbDrone.Web.Controllers
_notificationProvider = notificationProvider; _notificationProvider = notificationProvider;
_diskProvider = diskProvider; _diskProvider = diskProvider;
_seriesProvider = seriesProvider; _seriesProvider = seriesProvider;
_progressNotification = new ProgressNotification("Settings");
} }
public ActionResult Test() public ActionResult Test()
@ -273,7 +270,8 @@ namespace NzbDrone.Web.Controllers
[HttpPost] [HttpPost]
public ActionResult SaveIndexers(IndexerSettingsModel data) public ActionResult SaveIndexers(IndexerSettingsModel data)
{ {
_notificationProvider.Register(_progressNotification); var progressNotification = new ProgressNotification("Settings");
_notificationProvider.Register(progressNotification);
if (ModelState.IsValid) if (ModelState.IsValid)
{ {
@ -305,20 +303,21 @@ namespace NzbDrone.Web.Controllers
_configProvider.NewzbinUsername = data.NewzbinUsername; _configProvider.NewzbinUsername = data.NewzbinUsername;
_configProvider.NewzbinPassword = data.NewzbinPassword; _configProvider.NewzbinPassword = data.NewzbinPassword;
_progressNotification.CurrentMessage = SETTINGS_SAVED; progressNotification.CurrentMessage = SETTINGS_SAVED;
_progressNotification.Status = ProgressNotificationStatus.Completed; progressNotification.Status = ProgressNotificationStatus.Completed;
return Content(SETTINGS_SAVED); return Content(SETTINGS_SAVED);
} }
_progressNotification.CurrentMessage = SETTINGS_FAILED; progressNotification.CurrentMessage = SETTINGS_FAILED;
_progressNotification.Status = ProgressNotificationStatus.Completed; progressNotification.Status = ProgressNotificationStatus.Completed;
return Content(SETTINGS_FAILED); return Content(SETTINGS_FAILED);
} }
[HttpPost] [HttpPost]
public ActionResult SaveSabnzbd(SabnzbdSettingsModel data) public ActionResult SaveSabnzbd(SabnzbdSettingsModel data)
{ {
_notificationProvider.Register(_progressNotification); var progressNotification = new ProgressNotification("Settings");
_notificationProvider.Register(progressNotification);
if (ModelState.IsValid) if (ModelState.IsValid)
{ {
@ -331,20 +330,21 @@ namespace NzbDrone.Web.Controllers
_configProvider.SabTvPriority = data.SabTvPriority; _configProvider.SabTvPriority = data.SabTvPriority;
_configProvider.SabDropDirectory = data.SabDropDirectory; _configProvider.SabDropDirectory = data.SabDropDirectory;
_progressNotification.CurrentMessage = SETTINGS_SAVED; progressNotification.CurrentMessage = SETTINGS_SAVED;
_progressNotification.Status = ProgressNotificationStatus.Completed; progressNotification.Status = ProgressNotificationStatus.Completed;
return Content(SETTINGS_SAVED); return Content(SETTINGS_SAVED);
} }
_progressNotification.CurrentMessage = SETTINGS_FAILED; progressNotification.CurrentMessage = SETTINGS_FAILED;
_progressNotification.Status = ProgressNotificationStatus.Completed; progressNotification.Status = ProgressNotificationStatus.Completed;
return Content(SETTINGS_FAILED); return Content(SETTINGS_FAILED);
} }
[HttpPost] [HttpPost]
public ActionResult SaveQuality(QualityModel data) public ActionResult SaveQuality(QualityModel data)
{ {
_notificationProvider.Register(_progressNotification); var progressNotification = new ProgressNotification("Settings");
_notificationProvider.Register(progressNotification);
if (ModelState.IsValid) if (ModelState.IsValid)
{ {
@ -377,20 +377,21 @@ namespace NzbDrone.Web.Controllers
_qualityProvider.Update(profile); _qualityProvider.Update(profile);
} }
_progressNotification.CurrentMessage = SETTINGS_SAVED; progressNotification.CurrentMessage = SETTINGS_SAVED;
_progressNotification.Status = ProgressNotificationStatus.Completed; progressNotification.Status = ProgressNotificationStatus.Completed;
return Content(SETTINGS_SAVED); return Content(SETTINGS_SAVED);
} }
_progressNotification.CurrentMessage = SETTINGS_FAILED; progressNotification.CurrentMessage = SETTINGS_FAILED;
_progressNotification.Status = ProgressNotificationStatus.Completed; progressNotification.Status = ProgressNotificationStatus.Completed;
return Content(SETTINGS_FAILED); return Content(SETTINGS_FAILED);
} }
[HttpPost] [HttpPost]
public ActionResult SaveNotifications(NotificationSettingsModel data) public ActionResult SaveNotifications(NotificationSettingsModel data)
{ {
_notificationProvider.Register(_progressNotification); var progressNotification = new ProgressNotification("Settings");
_notificationProvider.Register(progressNotification);
if (ModelState.IsValid) if (ModelState.IsValid)
{ {
@ -407,20 +408,21 @@ namespace NzbDrone.Web.Controllers
_configProvider.XbmcUsername = data.XbmcUsername; _configProvider.XbmcUsername = data.XbmcUsername;
_configProvider.XbmcPassword = data.XbmcPassword; _configProvider.XbmcPassword = data.XbmcPassword;
_progressNotification.CurrentMessage = SETTINGS_SAVED; progressNotification.CurrentMessage = SETTINGS_SAVED;
_progressNotification.Status = ProgressNotificationStatus.Completed; progressNotification.Status = ProgressNotificationStatus.Completed;
return Content(SETTINGS_SAVED); return Content(SETTINGS_SAVED);
} }
_progressNotification.CurrentMessage = SETTINGS_FAILED; progressNotification.CurrentMessage = SETTINGS_FAILED;
_progressNotification.Status = ProgressNotificationStatus.Completed; progressNotification.Status = ProgressNotificationStatus.Completed;
return Content(SETTINGS_FAILED); return Content(SETTINGS_FAILED);
} }
[HttpPost] [HttpPost]
public ActionResult SaveEpisodeSorting(EpisodeSortingModel data) public ActionResult SaveEpisodeSorting(EpisodeSortingModel data)
{ {
_notificationProvider.Register(_progressNotification); var progressNotification = new ProgressNotification("Settings");
_notificationProvider.Register(progressNotification);
if (ModelState.IsValid) if (ModelState.IsValid)
{ {
@ -434,13 +436,13 @@ namespace NzbDrone.Web.Controllers
_configProvider.SortingNumberStyle = data.NumberStyle; _configProvider.SortingNumberStyle = data.NumberStyle;
_configProvider.SortingMultiEpisodeStyle = data.MultiEpisodeStyle; _configProvider.SortingMultiEpisodeStyle = data.MultiEpisodeStyle;
_progressNotification.CurrentMessage = SETTINGS_SAVED; progressNotification.CurrentMessage = SETTINGS_SAVED;
_progressNotification.Status = ProgressNotificationStatus.Completed; progressNotification.Status = ProgressNotificationStatus.Completed;
return Content(SETTINGS_SAVED); return Content(SETTINGS_SAVED);
} }
_progressNotification.CurrentMessage = SETTINGS_FAILED; progressNotification.CurrentMessage = SETTINGS_FAILED;
_progressNotification.Status = ProgressNotificationStatus.Completed; progressNotification.Status = ProgressNotificationStatus.Completed;
return Content(SETTINGS_FAILED); return Content(SETTINGS_FAILED);
} }
} }