private Response SaveAdmin() { var model = this.Bind <PlexRequestSettings>(); var valid = this.Validate(model); if (!valid.IsValid) { return(Response.AsJson(valid.SendJsonError())); } if (!string.IsNullOrWhiteSpace(model.BaseUrl)) { if (model.BaseUrl.StartsWith("/") || model.BaseUrl.StartsWith("\\")) { model.BaseUrl = model.BaseUrl.Remove(0, 1); } } var result = PrService.SaveSettings(model); if (result) { return(Response.AsJson(new JsonResponseModel { Result = true })); } return(Response.AsJson(new JsonResponseModel { Result = false, Message = "We could not save to the database, please try again" })); }
private async Task <Response> SaveAdmin() { var model = this.Bind <PlexRequestSettings>(); var valid = this.Validate(model); if (!valid.IsValid) { return(Response.AsJson(valid.SendJsonError())); } model.Wizard = true; if (!string.IsNullOrWhiteSpace(model.BaseUrl)) { if (model.BaseUrl.StartsWith("/", StringComparison.CurrentCultureIgnoreCase) || model.BaseUrl.StartsWith("\\", StringComparison.CurrentCultureIgnoreCase)) { model.BaseUrl = model.BaseUrl.Remove(0, 1); } } if (!model.CollectAnalyticData) { Analytics.TrackEventAsync(Category.Admin, Action.Save, "CollectAnalyticData turned off", Username, CookieHelper.GetAnalyticClientId(Cookies)); } var result = PrService.SaveSettings(model); Analytics.TrackEventAsync(Category.Admin, Action.Save, "PlexRequestSettings", Username, CookieHelper.GetAnalyticClientId(Cookies)); return(Response.AsJson(result ? new JsonResponseModel { Result = true } : new JsonResponseModel { Result = false, Message = "We could not save to the database, please try again" })); }
private Response SaveAdmin() { var model = this.Bind <PlexRequestSettings>(); PrService.SaveSettings(model); return(Context.GetRedirect(!string.IsNullOrEmpty(BaseUrl) ? $"~/{BaseUrl}/admin" : "~/admin")); }
private Response CreateApiKey() { this.RequiresClaims(UserClaims.Admin); var apiKey = Guid.NewGuid().ToString("N"); var settings = PrService.GetSettings(); settings.ApiKey = apiKey; PrService.SaveSettings(settings); return(Response.AsJson(apiKey)); }
private Response CreateApiKey() { Analytics.TrackEventAsync(Category.Admin, Action.Create, "Created API Key", Username, CookieHelper.GetAnalyticClientId(Cookies)); var apiKey = Guid.NewGuid().ToString("N"); var settings = PrService.GetSettings(); settings.ApiKey = apiKey; PrService.SaveSettings(settings); return(Response.AsJson(apiKey)); }