internal SetUserSettingResponse SetValue(string name, string value) { SetUserSettingResponse userSettingResponse = new SetUserSettingResponse(); if (name == "tz") { try { TimeZoneInfo timeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById(value); userSettingResponse.AddInfo($"timezone for {UserName} updated to {timeZoneInfo.Id}"); TimeZoneId = timeZoneInfo.Id; } catch { userSettingResponse.AddError($"Invalid Time Zone."); foreach (var tz in TimeZoneInfo.GetSystemTimeZones()) { if (tz.Id.ToLower().Contains(value.ToLower())) { userSettingResponse.AddError($"Possible matches: {tz.Id}?"); } } } } return(userSettingResponse); }
public SetUserSettingResponse SetUserSetting(string user, string name, string value) { UserSettings userSettings; if (!_userSettings.TryGetValue(user, out userSettings)) { userSettings = new UserSettings(user); _userSettings.Add(user, userSettings); } SetUserSettingResponse response = userSettings.SetValue(name, value); SaveStateManager.Service.StateChanged(this.GetType().Name); return(response); }