Example #1
0
        //   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();
        }
Example #2
0
        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
            });
        }
Example #3
0
        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
            });
        }
Example #4
0
        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
            });
        }