private void ToggleSwitch_Toggled(object sender, RoutedEventArgs e) { ToggleSwitch toggleSwitch = (ToggleSwitch)sender; CloureSetting setting = (CloureSetting)toggleSwitch.Tag; setting.Value = toggleSwitch.IsOn; }
public async static Task <List <ModuleSettings> > GetList() { List <ModuleSettings> items = new List <ModuleSettings>(); try { List <CloureParam> cparams = new List <CloureParam>(); cparams.Add(new CloureParam("module", "settings")); cparams.Add(new CloureParam("topic", "get_list")); string res = await CloureManager.ExecuteAsync(cparams); JsonObject api_result = JsonObject.Parse(res); string error = api_result.GetNamedString("Error"); if (error == "") { JsonObject api_response = api_result.GetNamedObject("Response"); JsonArray registers = api_response.GetNamedArray("Registros"); foreach (JsonValue jsonValue in registers) { JsonObject register = jsonValue.GetObject(); ModuleSettings moduleSettings = new ModuleSettings(); moduleSettings.CloureSettings = new List <CloureSetting>(); moduleSettings.ModuleTitle = register.GetNamedString("Title"); moduleSettings.ModuleId = register.GetNamedString("Id"); JsonArray privileges_tmp = register.GetNamedArray("Settings"); foreach (JsonValue privilege_tmp in privileges_tmp) { JsonObject privilegeObj = privilege_tmp.GetObject(); CloureSetting item = new CloureSetting(); item.Id = privilegeObj.GetNamedString("Id"); item.Title = privilegeObj.GetNamedString("Titulo"); item.Type = privilegeObj.GetNamedString("Tipo"); item.Value = privilegeObj.GetNamedString("Valor"); moduleSettings.CloureSettings.Add(item); } items.Add(moduleSettings); } } else { throw new Exception(error); } } catch (Exception ex) { var dialog = new MessageDialog(ex.Message); await dialog.ShowAsync(); } return(items); }