public ContactBook() { if (File.Exists("persons.xml")) { addresses = XMLFILE.READXML(); } else { addresses = new List <Contact>(); } }
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); }
public bool remove(string phone) { Contact addr = find(phone); if (addr != null) { addresses.Remove(addr); XMLFILE.WriteXML(addresses); return(true); } else { return(false); } }
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); } }