public void onSave(object sender, EventArgs e) { if (!common.validate()) { return; } var newstepList = new List <CulculateFormulaJsonModel>(); foreach (var target in editList) { var newstep = new CulculateFormulaJsonModel(); var newstepexelist = new List <ExecuteJsonModel>(); newstep.explain = target.explain.Text; if (target.final == null) { newstep.last = false; newstep.execute = newstepexelist; newstepList.Add(newstep); continue; } newstep.last = target.final.IsToggled; foreach (CulcModel cul in target.culculates) { var newexe = new ExecuteJsonModel(); string xtypeselect = SpecialUtil.typeConvertList[cul.xtypePick.Items[cul.xtypePick.SelectedIndex]]; string ytypeselect = SpecialUtil.typeConvertList[cul.ytypePick.Items[cul.ytypePick.SelectedIndex]]; newexe.culculateMethod = U.getMethodNameFromMark(cul.culcPick.Items[cul.culcPick.SelectedIndex]); newexe.xtype = xtypeselect; newexe.ytype = ytypeselect; switch (xtypeselect) { case JAN.Type_Constant_Value: newexe.xtarget = cul.xConstantEntry.Text; break; case JAN.Type_Input_Value: case JAN.Type_Last_Culculate_Result_Value: newexe.xtarget = cul.xstepPick.SelectedIndex.ToString(); break; } switch (ytypeselect) { case JAN.Type_Constant_Value: newexe.ytarget = cul.yConstantEntry.Text; break; case JAN.Type_Input_Value: case JAN.Type_Last_Culculate_Result_Value: newexe.ytarget = cul.ystepPick.SelectedIndex.ToString(); break; default: break; } newstepexelist.Add(newexe); } newstep.execute = newstepexelist; newstepList.Add(newstep); } var cj = new CulculateJsonModel(); cj.formula = newstepList; string json = Newtonsoft.Json.JsonConvert.SerializeObject(cj); UserCulculateModel um = new UserCulculateModel(); um.Culculate = json; um.Name = "Special"; um.DisplayName = common.nameEntry.Text; um.Index = 0; UserCulculateUtil.insertUserCulculate(um); mypair.refreshEditList(); mypair.DisplayAlert("確認", "新しい計算を作成しました。", "OK"); }
public async void onSave(object sender, EventArgs e) { var result = await mypair.DisplayAlert("確認", "計算を更新しますか?", "OK", "キャンセル"); if (!result) { return; } if (!common.validate()) { return; } var newstepList = new List <CulculateFormulaJsonModel>(); foreach (var target in editList) { var newstep = new CulculateFormulaJsonModel(); var newstepexelist = new List <ExecuteJsonModel>(); newstep.explain = target.explain.Text; if (target.final == null) { newstep.last = false; newstep.execute = newstepexelist; newstepList.Add(newstep); continue; } newstep.last = target.final.IsToggled; foreach (CulcModel cul in target.culculates) { var newexe = new ExecuteJsonModel(); string xtypeselect = SpecialUtil.typeConvertList[cul.xtypePick.Items[cul.xtypePick.SelectedIndex]]; string ytypeselect = SpecialUtil.typeConvertList[cul.ytypePick.Items[cul.ytypePick.SelectedIndex]]; newexe.culculateMethod = U.getMethodNameFromMark(cul.culcPick.Items[cul.culcPick.SelectedIndex]); newexe.xtype = xtypeselect; newexe.ytype = ytypeselect; switch (xtypeselect) { case JAN.Type_Constant_Value: newexe.xtarget = cul.xConstantEntry.Text; break; case JAN.Type_Input_Value: case JAN.Type_Last_Culculate_Result_Value: newexe.xtarget = cul.xstepPick.SelectedIndex.ToString(); break; } switch (ytypeselect) { case JAN.Type_Constant_Value: newexe.ytarget = cul.yConstantEntry.Text; break; case JAN.Type_Input_Value: case JAN.Type_Last_Culculate_Result_Value: newexe.ytarget = cul.ystepPick.SelectedIndex.ToString(); break; } newstepexelist.Add(newexe); } newstep.execute = newstepexelist; newstepList.Add(newstep); } var cj = new CulculateJsonModel(); cj.formula = newstepList; string json = JsonConvert.SerializeObject(cj); UserCulculateUtil.updateCulculateById(myUserCulculateModelTarget.Id, "Special", json, common.nameEntry.Text); mypair.refreshEditList(); await mypair.DisplayAlert("確認", "更新が完了しました", "OK"); }