public void updateHostingUnit(HostingUnit hostingUnit)
        {
            XElement HostingUnitElement = (from item in HostingUnitRoot.Elements()
                                           where int.Parse(item.Element("HostingUnitKey").Value) == hostingUnit.HostingUnitKey
                                           select item).FirstOrDefault();

            if (HostingUnitElement == null)
            {
                throw new Exception("יחדית האירוח לא נימצאה");
            }

            HostingUnitElement.Element("HostingUnitKey").Value  = hostingUnit.HostingUnitKey.ToString();
            HostingUnitElement.Element("Area").Value            = hostingUnit.Area.ToString();
            HostingUnitElement.Element("HostingUnitName").Value = hostingUnit.HostingUnitName.ToString();
            HostingUnitElement.Element("AllDates").Value        = ListDateTimeToString(hostingUnit.AllDates);
            HostingUnitElement.Element("Owner").Element("OwnerHostKey").Value                        = hostingUnit.Owner.HostKey.ToString();
            HostingUnitElement.Element("Owner").Element("OwnerBankAccountNumber").Value              = hostingUnit.Owner.BankAccountNumber.ToString();
            HostingUnitElement.Element("Owner").Element("OwnerMailAddress").Value                    = hostingUnit.Owner.MailAddress.ToString();
            HostingUnitElement.Element("Owner").Element("OwnerFamilyName").Value                     = hostingUnit.Owner.FamilyName.ToString();
            HostingUnitElement.Element("Owner").Element("OwnerPrivateName").Value                    = hostingUnit.Owner.PrivateName.ToString();
            HostingUnitElement.Element("Owner").Element("OwnerCollectionClearance").Value            = hostingUnit.Owner.CollectionClearance.ToString();
            HostingUnitElement.Element("Owner").Element("BankBranch").Element("BankName").Value      = hostingUnit.Owner.BankBranchDetails.BankName.ToString();
            HostingUnitElement.Element("Owner").Element("BankBranch").Element("BankName").Value      = hostingUnit.Owner.BankBranchDetails.BankName.ToString();
            HostingUnitElement.Element("Owner").Element("BankBranch").Element("BranchAddress").Value = hostingUnit.Owner.BankBranchDetails.BranchAddress.ToString();
            HostingUnitElement.Element("Owner").Element("BankBranch").Element("BranchCity").Value    = hostingUnit.Owner.BankBranchDetails.BranchCity.ToString();
            HostingUnitElement.Element("Owner").Element("BankBranch").Element("BranchNumber").Value  = hostingUnit.Owner.BankBranchDetails.BranchNumber.ToString();

            HostingUnitRoot.Save(HostingUnitPath);
        }
        public void addHostingUnit(HostingUnit hostingUnit)
        {
            hostingUnit.HostingUnitKey = getAndUpdateHostingUnitConfig();
            hostingUnit.AllDates       = new List <DateTime>();

            XElement HostingUnitKey  = new XElement("HostingUnitKey", hostingUnit.HostingUnitKey);
            XElement AllDates        = new XElement("AllDates", ListDateTimeToString(hostingUnit.AllDates));
            XElement Area            = new XElement("Area", hostingUnit.Area);
            XElement HostingUnitName = new XElement("HostingUnitName", hostingUnit.HostingUnitName);

            XElement OwnerPrivateName         = new XElement("OwnerPrivateName", hostingUnit.Owner.PrivateName);
            XElement OwnerFamilyName          = new XElement("OwnerFamilyName", hostingUnit.Owner.FamilyName);
            XElement OwnerFhoneNumber         = new XElement("OwnerFhoneNumber", hostingUnit.Owner.FhoneNumber);
            XElement OwnerHostKey             = new XElement("OwnerHostKey", hostingUnit.Owner.HostKey);
            XElement OwnerMailAddress         = new XElement("OwnerMailAddress", hostingUnit.Owner.MailAddress);
            XElement OwnerBankAccountNumber   = new XElement("OwnerBankAccountNumber", hostingUnit.Owner.BankAccountNumber);
            XElement OwnerCollectionClearance = new XElement("OwnerCollectionClearance", hostingUnit.Owner.CollectionClearance);

            XElement BankName      = new XElement("BankName", hostingUnit.Owner.BankBranchDetails.BankName);
            XElement BankNumber    = new XElement("BankNumber", hostingUnit.Owner.BankBranchDetails.BankNumber);
            XElement BranchAddress = new XElement("BranchAddress", hostingUnit.Owner.BankBranchDetails.BranchAddress);
            XElement BranchCity    = new XElement("BranchCity", hostingUnit.Owner.BankBranchDetails.BranchCity);
            XElement BranchNumber  = new XElement("BranchNumber", hostingUnit.Owner.BankBranchDetails.BranchNumber);

            XElement Branch = new XElement("BankBranch", BankName, BankNumber, BranchAddress, BranchCity, BranchNumber);

            XElement Owner = new XElement("Owner", OwnerPrivateName, OwnerFamilyName, OwnerFhoneNumber, OwnerHostKey, OwnerMailAddress, OwnerCollectionClearance, OwnerBankAccountNumber, Branch);

            HostingUnitRoot.Add(new XElement("HostingUnit", HostingUnitKey, AllDates, Area, HostingUnitName, Owner));
            HostingUnitRoot.Save(HostingUnitPath);
        }
        public bool deleteHostingUnit(long key)
        {
            XElement HostingUnitElement;

            try
            {
                HostingUnitElement = (from item in HostingUnitRoot.Elements()
                                      where long.Parse(item.Element("HostingUnitKey").Value) == key
                                      select item).FirstOrDefault();
                HostingUnitElement.Remove();
                HostingUnitRoot.Save(HostingUnitPath);
                return(true);
            }
            catch
            {
                return(false);
            }
        }