public PartialViewResult GetPluginSettings(long projectId, long pluginId) { var settings = _apiService .GetPluginSettingsForProject(pluginId, projectId) .Select(_ => _.ToModel()) .ToList(); var model = new PluginSettingsModel { PluginId = pluginId, ProjectId = projectId, Settings = settings }; return(PartialView(model)); }
public ActionResult SavePluginSettings(PluginSettingsModel model) { _apiService.UpdatePluginSettings( model.ProjectId, model.PluginId, new UpdateProjectPluginSettingsDto { Settings = model.Settings .Select(s => new UpdateProjectPluginSettingDto { SettingId = s.SettingId, Value = s.Value }) .ToArray() }); return(RedirectToAction("Edit", new { projectId = model.ProjectId })); }
public static T Create <T> (string pluginId) where T : PluginSettingsModel { PluginSettingsModel rtnModel = new PluginSettingsModel(); string pluginDir = Path.Combine(PluginPathProvider.PluginsRootPath(), pluginId); string pluginSettingsFilePath = Path.Combine(pluginDir, SettingsFile); if (!File.Exists(pluginSettingsFilePath)) { return(null); } try { string settingsStr = File.ReadAllText(pluginSettingsFilePath, Encoding.UTF8); rtnModel = System.Text.Json.JsonSerializer.Deserialize <T>(settingsStr); } catch (Exception ex) { rtnModel = null; } return(rtnModel as T); }