Settings done for #298

This commit is contained in:
tidusjar 2016-06-06 17:19:56 +01:00
parent 0dd30968d5
commit 66bede34f4
4 changed files with 45 additions and 36 deletions

View file

@ -191,7 +191,7 @@ namespace PlexRequests.UI.Modules
Post["/slacknotification"] = _ => SaveSlackNotifications();
Get["/landingpage", true] = async (x,ct) => await LandingPage();
Post["/landingpage"] = _ => SaveSlackNotifications();
Post["/landingpage", true] = async (x, ct) => await SaveLandingPage();
}
private Negotiator Authentication()
@ -819,5 +819,21 @@ namespace PlexRequests.UI.Modules
return View["LandingPage", settings];
}
private async Task<Response> SaveLandingPage()
{
var settings = this.Bind<LandingPageSettings>();
if (settings.Enabled && settings.EnabledNoticeTime && string.IsNullOrEmpty(settings.NoticeMessage))
{
return Response.AsJson(new JsonResponseModel { Result = false, Message = "If you are going to enabled the notice, then we need a message!"});
}
var result = await LandingSettings.SaveSettingsAsync(settings);
return Response.AsJson(result
? new JsonResponseModel { Result = true }
: new JsonResponseModel { Result = false, Message = "Could not save to Db Please check the logs"});
}
}
}