Пример #1
0
        string file_path = Utilities.PersonJsonFile.FullFilePath(); //Use "PersonJsonFile" to include file name to "FullFilePath"
        //string file_path = bll_Utilities.PersonJsonFilePath;
        public bool Create(Person obj)
        {
            try
            {
                List <Person> people = PersonJsonProcessor.getJsonDataObject(file_path);

                int currentId = 1;

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

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

                obj.Id = currentId;

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

                return(true);
            }
            catch (System.Exception ex)
            {
                string error = "Create person json file exceptio: " + ex.Message;
                ErrorHandling.WriteError(error);
                return(false);
            }
        }
Пример #2
0
 public List <Person> RetrieveAll()
 {
     return(PersonJsonProcessor.getJsonDataObject(file_path));
 }