public IActionResult SaveSettings([FromBody] CoreSettingsModel model) { try { if (model == null || string.IsNullOrEmpty(model.Key)) { return(BadRequest(new { error = "params", message = "Key is empty" })); } if (string.IsNullOrEmpty(model.Value)) { return(BadRequest(new { error = "params", message = "Value is empty" })); } var tenant = model.Tenant; if (tenant < -1) { tenant = -1; } CoreSettings.SaveSetting(model.Key, model.Value, tenant); var settings = CoreSettings.GetSetting(model.Key, tenant); return(Ok(new { settings })); } catch (ArgumentException ae) { Log.Error(ae); return(StatusCode(StatusCodes.Status500InternalServerError, new { error = "params", message = ae.Message })); } catch (Exception e) { Log.Error(e); return(StatusCode(StatusCodes.Status500InternalServerError, new { error = "error", message = e.Message })); } }
public ISettings GetDefault(CoreSettings coreSettings) { if (_default != null) { return(_default); } var settings = coreSettings.GetSetting("CompanyWhiteLabelSettings"); _default = string.IsNullOrEmpty(settings) ? new CompanyWhiteLabelSettings() : JsonConvert.DeserializeObject <CompanyWhiteLabelSettings>(settings); return(_default); }
public IActionResult GetSettings(int tenant, string key) { try { if (tenant < -1) { return(BadRequest(new { error = "portalNameIncorrect", message = "Tenant is incorrect" })); } if (string.IsNullOrEmpty(key)) { return(BadRequest(new { error = "params", message = "Key is empty" })); } var settings = CoreSettings.GetSetting(key, tenant); return(Ok(new { settings })); } catch (ArgumentException ae) { Log.Error(ae); return(StatusCode(StatusCodes.Status500InternalServerError, new { error = "error", message = ae.Message })); } catch (Exception e) { Log.Error(e); return(StatusCode(StatusCodes.Status500InternalServerError, new { error = "error", message = e.Message })); } }
private string GetUrlSetting(string key, string appSettingsKey = null) { var value = string.Empty; if (CoreBaseSettings.Standalone) { value = CoreSettings.GetSetting(GetSettingsKey(key)); } if (string.IsNullOrEmpty(value)) { value = Configuration["files:docservice:url:" + (appSettingsKey ?? key)]; } return(value); }
public string GetDocDbKey() { const string dbKey = "UniqueDocument"; var resultKey = CoreSettings.GetSetting(dbKey); if (!string.IsNullOrEmpty(resultKey)) { return(resultKey); } resultKey = Guid.NewGuid().ToString(); CoreSettings.SaveSetting(dbKey, resultKey); return(resultKey); }
private string Get(string name) { string value = null; if (!OnlyDefault && CanSet) { var tenant = CoreBaseSettings.Standalone ? Tenant.DEFAULT_TENANT : TenantManager.GetCurrentTenant().TenantId; value = CoreSettings.GetSetting(GetSettingsKey(name), tenant); } if (string.IsNullOrEmpty(value)) { if (AllProps.ContainsKey(name)) { value = AllProps[name]; } } return(value); }
public IActionResult GetSettings([FromQuery] SettingsModel model) { if (!GetTenant(model, out int tenantId, out object error)) { return(BadRequest(error)); } if (string.IsNullOrEmpty(model.Key)) { return(BadRequest(new { error = "params", message = "Key is required" })); } var settings = CoreSettings.GetSetting(model.Key, tenantId); return(Ok(new { settings })); }
public IActionResult SaveSettings([FromBody] SettingsModel model) { if (!GetTenant(model, out int tenantId, out object error)) { return(BadRequest(error)); } if (string.IsNullOrEmpty(model.Key)) { return(BadRequest(new { error = "params", message = "Key is required" })); } if (string.IsNullOrEmpty(model.Value)) { return(BadRequest(new { error = "params", message = "Value is empty" })); } Log.DebugFormat("Set {0} value {1} for {2}", model.Key, model.Value, tenantId); CoreSettings.SaveSetting(model.Key, model.Value, tenantId); var settings = CoreSettings.GetSetting(model.Key, tenantId); return(Ok(new { settings })); }