Пример #1
0
        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);
            }
        }
Пример #2
0
 private Data()
 {
     source   = new DataXML();
     projects = source.projects;
 }
Пример #3
0
 public void Set(iData data)
 {
     Data = data as Data4Charator;
 }
Пример #4
0
 public void Set(iData data)
 {
     Data = data as Data4Charator;
 }