public void updateHost(Host host)
        {
            XElement HostElement = (from item in HostRoot.Elements()
                                    where int.Parse(item.Element("HostKey").Value) == host.HostKey
                                    select item).FirstOrDefault();

            if (HostElement == null)
            {
                throw new Exception("התעודת זהות שהוזנה לא מייצגת מארח במערכת");
            }


            HostElement.Element("name").Element("PrivateName").Value = host.PrivateName;
            HostElement.Element("name").Element("FamilyName").Value  = host.FamilyName;
            HostElement.Element("MailAddress").Value         = host.MailAddress;
            HostElement.Element("FhoneNumber").Value         = host.FhoneNumber;
            HostElement.Element("BankAccountNumber").Value   = host.BankAccountNumber.ToString();
            HostElement.Element("CollectionClearance").Value = host.CollectionClearance.ToString();
            HostElement.Element("BankBranchDetails").Element("Bank").Element("BankName").Value         = host.BankBranchDetails.BankName;
            HostElement.Element("BankBranchDetails").Element("Bank").Element("BankNumber").Value       = host.BankBranchDetails.BankNumber.ToString();
            HostElement.Element("BankBranchDetails").Element("Address").Element("BranchAddress").Value = host.BankBranchDetails.BranchAddress;
            HostElement.Element("BankBranchDetails").Element("Address").Element("BranchCity").Value    = host.BankBranchDetails.BranchCity;
            HostElement.Element("BankBranchDetails").Element("BranchNumber").Value = host.BankBranchDetails.BranchNumber.ToString();

            HostRoot.Save(HostPath);
        }
        public void addHost(Host host)
        {
            Host tempHost = getListHosts().FirstOrDefault(host1 => host1.HostKey == host.HostKey);

            if (tempHost != null)
            {
                throw new Exception("יש כבר מארח עם אותו תעודת זהות");
            }
            else
            {
                XElement HostKey           = new XElement("HostKey", host.HostKey);
                XElement FhoneNumber       = new XElement("FhoneNumber", host.FhoneNumber);
                XElement BankAccountNumber = new XElement("BankAccountNumber", host.BankAccountNumber);
                XElement PrivateName       = new XElement("PrivateName", host.PrivateName);
                XElement FamilyName        = new XElement("FamilyName", host.FamilyName);
                XElement name                = new XElement("name", PrivateName, FamilyName);
                XElement MailAddress         = new XElement("MailAddress", host.MailAddress);
                XElement CollectionClearance = new XElement("CollectionClearance", host.CollectionClearance);

                XElement BankNumber    = new XElement("BankNumber", host.BankBranchDetails.BankNumber);
                XElement BankName      = new XElement("BankName", host.BankBranchDetails.BankName);
                XElement Bank          = new XElement("Bank", BankNumber, BankName);
                XElement BranchNumber  = new XElement("BranchNumber", host.BankBranchDetails.BranchNumber);
                XElement BranchAddress = new XElement("BranchAddress", host.BankBranchDetails.BranchAddress);
                XElement BranchCity    = new XElement("BranchCity", host.BankBranchDetails.BranchCity);
                XElement Address       = new XElement("Address", BranchAddress, BranchCity);


                XElement BankBranchDetails = new XElement("BankBranchDetails", Bank, BranchNumber, Address);

                HostRoot.Add(new XElement("Host", HostKey, name, FhoneNumber, BankAccountNumber, MailAddress, CollectionClearance, BankBranchDetails));
                HostRoot.Save(HostPath);
            }
        }
        public bool deleteHost(long key)
        {
            XElement Hostelement;

            try
            {
                Hostelement = (from item in HostRoot.Elements()
                               where int.Parse(item.Element("HostKey").Value) == key
                               select item).FirstOrDefault();
                Hostelement.Remove();
                HostRoot.Save(HostPath);
                return(true);
            }
            catch
            {
                return(false);
            }
        }