public int CreateUpdateData(string id, string data) { try { var userList = getall(); var isExist = userList.Exists(s => s.Id == id); if (isExist) { var u = getDataById(id); for (var i = 0; i < userList.Count; i++) { if (userList[i].Id == id) { userList.Remove(userList[i]); i--; } } } iData userInfo = new iData(); userInfo.Id = id; userInfo.Data = data; userList.Add(userInfo); var userdata = JsonConvert.SerializeObject(userList); var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"datajson\productdata.json"); File.WriteAllText(path, userdata); return(1); } catch (Exception ex) { return(-1); } }
private Data() { source = new DataXML(); projects = source.projects; }
public void Set(iData data) { Data = data as Data4Charator; }