Пример #1
0
 public ContactBook()
 {
     if (File.Exists("persons.xml"))
     {
         addresses = XMLFILE.READXML();
     }
     else
     {
         addresses = new List <Contact>();
     }
 }
Пример #2
0
        public void update(Contact addr)
        {
            Console.WriteLine("Edit contact: ");
            Console.WriteLine("Enter Name: ");
            addr.Name = Console.ReadLine();
            Console.WriteLine("Enter Last Name: ");
            addr.LastName = Console.ReadLine();
            Console.WriteLine("Enter phone number: ");
            addr.Number = Console.ReadLine();
            Console.WriteLine("Address: ");
            addr.Address = Console.ReadLine();
            Console.WriteLine("Contact updated");

            XMLFILE.WriteXML(addresses);
        }
Пример #3
0
        public bool remove(string phone)
        {
            Contact addr = find(phone);

            if (addr != null)
            {
                addresses.Remove(addr);
                XMLFILE.WriteXML(addresses);
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #4
0
        public bool add(string name, string lastname, string number, string address)
        {
            Contact addr   = new Contact(name, lastname, number, address);
            Contact result = find(number);

            if (result == null) //if null = not found
            {
                addresses.Add(addr);
                XMLFILE.WriteXML(addresses);
                return(true);
            }
            else
            {
                return(false);
            }
        }