Beispiel #1
0
        private async Task <Response> SaveLandingPage()
        {
            var settings = this.Bind <LandingPageSettings>();

            Analytics.TrackEventAsync(Category.Admin, Action.Update, "Update Landing Page", Username, CookieHelper.GetAnalyticClientId(Cookies));
            var plexSettings = await PlexService.GetSettingsAsync();

            if (string.IsNullOrEmpty(plexSettings.Ip))
            {
                return(Response.AsJson(new JsonResponseModel {
                    Result = false, Message = "We cannot enable the landing page if Plex is not setup!"
                }));
            }

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