Esempio n. 1
0
        private Response SaveCouchPotato()
        {
            var couchPotatoSettings = this.Bind <CouchPotatoSettings>();
            var valid = this.Validate(couchPotatoSettings);

            if (!valid.IsValid)
            {
                return(Response.AsJson(valid.SendJsonError()));
            }

            var watcherSettings = WatcherSettings.GetSettings();

            if (watcherSettings.Enabled)
            {
                return
                    (Response.AsJson(new JsonResponseModel
                {
                    Result = false,
                    Message = "Cannot have Watcher and CouchPotato both enabled."
                }));
            }

            couchPotatoSettings.ApiKey = couchPotatoSettings.ApiKey.Trim();
            var result = CpService.SaveSettings(couchPotatoSettings);

            return(Response.AsJson(result
                ? new JsonResponseModel {
                Result = true, Message = "Successfully Updated the Settings for CouchPotato!"
            }
                : new JsonResponseModel {
                Result = false, Message = "Could not update the settings, take a look at the logs."
            }));
        }
Esempio n. 2
0
        private Response SaveCouchPotato()
        {
            var couchPotatoSettings = this.Bind <CouchPotatoSettings>();
            var valid = this.Validate(couchPotatoSettings);

            if (!valid.IsValid)
            {
                return(Response.AsJson(valid.SendJsonError()));
            }

            var result = CpService.SaveSettings(couchPotatoSettings);

            return(Response.AsJson(result
                ? new JsonResponseModel {
                Result = true, Message = "Successfully Updated the Settings for CouchPotato!"
            }
                : new JsonResponseModel {
                Result = false, Message = "Could not update the settings, take a look at the logs."
            }));
        }