using System; using System.Collections.Generic; using System.Linq; using Microsoft.AspNetCore.Http; using Core.Main; using Core.Helper; using Core.Main.DataObjects.PTMagicData; using Core.MarketAnalyzer; namespace Monitor.Pages { public class SettingsGlobalSettingsModel : _Internal.BasePageModelSecure { public GlobalSetting GlobalSetting = null; public string SettingName = ""; public void OnGet() { // Initialize Config base.Init(); BindData(); } private void BindData() { SettingName = this.GetStringParameter("gs", ""); if (!SettingName.Equals("")) { GlobalSetting = PTMagicConfiguration.AnalyzerSettings.GlobalSettings.Find(gs => SystemHelper.StripBadCode(gs.SettingName, Constants.WhiteListNames).Equals(SettingName)); } else { GlobalSetting = new GlobalSetting(); GlobalSetting.SettingName = "New Setting"; } } public string GetMarketTrendSelection(Trigger t) { string result = ""; foreach (MarketTrend mt in PTMagicConfiguration.AnalyzerSettings.MarketAnalyzer.MarketTrends) { string selected = ""; if (t != null) { if (t.MarketTrendName.Equals(mt.Name, StringComparison.InvariantCultureIgnoreCase)) { selected = " selected=\"selected\""; } } result += "" + mt.Name + ""; } return result; } public string GetValueModes(string propertyKey) { string result = ""; string selected = ""; if (propertyKey.IndexOf("_OFFSET", StringComparison.InvariantCultureIgnoreCase) == -1) { selected = " selected=\"selected\""; } result += "Flat value"; if (propertyKey.EndsWith("_OFFSET", StringComparison.InvariantCultureIgnoreCase)) { selected = " selected=\"selected\""; } else { selected = ""; } result += "Offset by flat value"; if (propertyKey.EndsWith("_OFFSETPERCENT", StringComparison.InvariantCultureIgnoreCase)) { selected = " selected=\"selected\""; } else { selected = ""; } result += "Offset by percent"; return result; } } }