// var list repo.GetList(); static void Main(string[] args) { Repository repo = new repository(); var data = File.ReadAllText(ConfigurationManager.AppSettings["file"]); //JObject jObject = JObject.Parse(data); //Console.WriteLine("Name : " + jObject["name"]); var personList = JsonConvert.DeserializeObject <List <Person> >(data); // personList.RemoveAt(1); string dataToSave = JsonConvert.SerializeObject(personList); File.WriteAllText((ConfigurationManager.AppSettings["file"]), dataToSave); repo.Add(new Person { LastName = "Zyhu", Name = "Ahdi", listOfObjects = new List <string> { "1", "2", "abc" } });;; string saveNewPerson = JsonConvert.SerializeObject(repo); File.WriteAllText(ConfigurationManager.AppSettings["file"], saveNewPerson); Console.Read(); }
public void AddBook() { var commands = new repository(); Console.WriteLine("Enter Name and year"); // считываем данные книги string name = Console.ReadLine(); //Author author = Console.ReadLine(); int year = int.Parse(Console.ReadLine()); commands.Add(new Book { name = name, year = year }); }
public void AddUser() { var commands = new repository(); Console.WriteLine("Enter mail, password and ID"); // считываем данные пользователя string mail = Console.ReadLine(); string password = Console.ReadLine(); int iD = int.Parse(Console.ReadLine()); commands.Add(new User { Password = password, Mail = mail, ID = iD }); }
public void AddAuthor() { var commands = new repository(); Console.WriteLine("Enter Name, Surname, Middle Nane and year born"); // считываем данные автора string name = Console.ReadLine(); string surname = Console.ReadLine(); string middleName = Console.ReadLine(); int born = int.Parse(Console.ReadLine()); commands.Add(new Author { name = name, surname = surname, middleName = middleName, born = born }); }