public static string edit_ItemJsonString(string item_json, string msg_default = "") { string json = msg_default; try { m_canhbao_cauhinh m = JsonConvert.DeserializeObject <m_canhbao_cauhinh>(item_json); int index = list.FindIndex(o => o.cauhinh_id == m.cauhinh_id); if (index != -1) { m_canhbao_cauhinh o = list[index]; o.name = m.name; o.note = m.note; lock (list) list[index] = o; update(); json = JsonConvert.SerializeObject(o); } } catch { } return(json); }
public static Tuple <bool, string, dynamic> edit(string s_key, string s_item) { try { string json = ""; var m = JsonConvert.DeserializeObject <m_canhbao_cauhinh>(s_item); int index = list.FindIndex(o => o.cauhinh_id == m.cauhinh_id); if (index != -1) { m_canhbao_cauhinh o = list[index]; o.name = m.name; o.note = m.note; lock (list) list[index] = o; update(); json = JsonConvert.SerializeObject(o); } return(new Tuple <bool, string, dynamic>(true, json, m)); } catch { } return(new Tuple <bool, string, dynamic>(false, "", null)); }
public static string get_ItemJsonBy_find_name(string name, string msg_default = "") { string json = msg_default; var ls = list.Where(x => x.name == name).ToList(); for (int k = 0; k < ls.Count; k++) { m_canhbao_cauhinh m = ls[k]; ls[k] = m; } json = JsonConvert.SerializeObject(ls); return(json); }