private async Task <Response> SaveCouchPotato() { var couchPotatoSettings = this.Bind <CouchPotatoSettings>(); var valid = this.Validate(couchPotatoSettings); if (!valid.IsValid) { return(Response.AsJson(valid.SendJsonError())); } var watcherSettings = await WatcherSettings.GetSettingsAsync(); if (watcherSettings.Enabled) { return (Response.AsJson(new JsonResponseModel { Result = false, Message = "Cannot have Watcher and CouchPotato both enabled." })); } var radarrSettings = await RadarrSettings.GetSettingsAsync(); if (radarrSettings.Enabled) { return (Response.AsJson(new JsonResponseModel { Result = false, Message = "Cannot have Radarr and CouchPotato both enabled." })); } couchPotatoSettings.ApiKey = couchPotatoSettings.ApiKey.Trim(); var result = await CpService.SaveSettingsAsync(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." })); }
private async Task <Response> GetCpProfiles() { var settings = this.Bind <CouchPotatoSettings>(); var valid = this.Validate(settings); if (!valid.IsValid) { return(Response.AsJson(valid.SendJsonError())); } var profiles = CpApi.GetProfiles(settings.FullUri, settings.ApiKey); // set the cache if (profiles != null) { Cache.Set(CacheKeys.CouchPotatoQualityProfiles, profiles); } // Save the first profile found (user might not press save...) settings.ProfileId = profiles?.list?.FirstOrDefault()?._id; await CpService.SaveSettingsAsync(settings); return(Response.AsJson(profiles)); }