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 IEnumerable <HostingUnit> getListHostingUnit(Func <HostingUnit, bool> predicate = null) { IEnumerable <HostingUnit> hostingUnits = (from item in HostingUnitRoot.Elements() where getHostingUnit(long.Parse(item.Element("HostingUnitKey").Value)) != null select getHostingUnit(long.Parse(item.Element("HostingUnitKey").Value))); if (predicate == null) { return(hostingUnits); } return(hostingUnits.Where(predicate)); }
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); } }
public HostingUnit getHostingUnit(long key) { HostingUnit hostingUnit; try { hostingUnit = (from item in HostingUnitRoot.Elements() where long.Parse(item.Element("HostingUnitKey").Value) == key select new HostingUnit() { HostingUnitKey = int.Parse(item.Element("HostingUnitKey").Value), Area = getEnumFromString <AreaEnum>(item.Element("Area").Value), HostingUnitName = item.Element("HostingUnitName").Value, AllDates = stringToListDateTime(item.Element("AllDates").Value), Owner = new Host() { HostKey = long.Parse(item.Element("Owner").Element("OwnerHostKey").Value), BankAccountNumber = int.Parse(item.Element("Owner").Element("OwnerBankAccountNumber").Value), FamilyName = item.Element("Owner").Element("OwnerFamilyName").Value, PrivateName = item.Element("Owner").Element("OwnerPrivateName").Value, MailAddress = item.Element("Owner").Element("OwnerMailAddress").Value, CollectionClearance = bool.Parse(item.Element("Owner").Element("OwnerCollectionClearance").Value), FhoneNumber = item.Element("Owner").Element("OwnerFhoneNumber").Value, BankBranchDetails = new BankBranch() { BankName = item.Element("Owner").Element("BankBranch").Element("BankName").Value, BankNumber = int.Parse(item.Element("Owner").Element("BankBranch").Element("BankNumber").Value), BranchAddress = item.Element("Owner").Element("BankBranch").Element("BranchAddress").Value, BranchCity = item.Element("Owner").Element("BankBranch").Element("BranchCity").Value, BranchNumber = int.Parse(item.Element("Owner").Element("BankBranch").Element("BranchNumber").Value) } } }).FirstOrDefault(); } catch { hostingUnit = null; } if (hostingUnit == null) { throw new Exception("מספר יחידת אירוח לא נכון"); } return(hostingUnit); }