Пример #1
0
        public bool Create(Tool obj)
        {
            try
            {
                List <Tool> tool = ToolJsonProcessor.getJsonDataObject(file_path);

                int currentId = 1;

                if (tool != null)
                {
                    currentId = tool.OrderByDescending(x => x.m_id).First().m_id + 1;
                }

                //if (people.Count > 0)
                //{
                //    currentId = people.OrderByDescending(x => x.Id).First().Id + 1;
                //}

                obj.m_id = currentId;

                string json_basedata = ToolJsonProcessor.getJsonDataString(file_path);
                string s             = ToolJsonProcessor.AddObjectsToJson(json_basedata, obj, file_path);

                return(true);
            }
            catch (System.Exception ex)
            {
                string error = "Create person json file exceptio: " + ex.Message;
                ErrorHandling.WriteError(error, error_folder);
                return(false);
            }
        }
Пример #2
0
        public bool Delete(string key)
        {
            int id = Int32.Parse(key);

            if (ToolJsonProcessor.DeleteRow(file_path, id))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #3
0
        public bool Update(Tool obj, string key)
        {
            int id = Int32.Parse(key);

            if (ToolJsonProcessor.UpdateRow(file_path, id, obj))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #4
0
 public List <Tool> RetrieveAll()
 {
     return(ToolJsonProcessor.getJsonDataObject(file_path));
 }