public static BE.MyGuest GetGuestFromXml(int i) { try { XElement MyGuest = XElement.Load(Path + "guest.xml"); var AllMyHost = (from MyHost in MyGuest.Elements() select new BE.MyGuest() { FirstName = MyHost.Element("FirstName").Value, LastName = MyHost.Element("LastName").Value, Id = MyHost.Element("Id").Value, Password = MyHost.Element("Password").Value, }).ToList(); return(AllMyHost[i]); } catch { throw new Exception("האורח לא קיים "); } }
public static BE.MyHost GetMyHostFromXml(int i) // קבלה על ידי מיקום { try { XElement MyHosts = XElement.Load(Path + "hosts.xml"); var AllMyHost = (from MyHost in MyHosts.Elements() select new BE.MyHost() { FirstName_host = MyHost.Element("FirstName_host").Value, LastName_host = MyHost.Element("LastName_host").Value, Id_host = MyHost.Element("Id_host").Value, Password_host = MyHost.Element("Password_host").Value, FhoneNumber = MyHost.Element("FhoneNumber").Value, MailAddress = MyHost.Element("MailAddress").Value, BankAccountNumber = int.Parse(MyHost.Element("BankAccountNumber").Value), CollectionClearance = (BE.My_enum.Yes_Or_No)Enum.Parse(typeof(BE.My_enum.Yes_Or_No), MyHost.Element("CollectionClearance").Value), //(from MyHost in MyHosts.Elements() select MyHost).ToList()[0].Element("BankAccuont").Element("BankName").Value BankAccuont = new BE.BankBranch() { BankNumber = int.Parse(MyHost.Element("BankAccuont").Element("BankNumber").Value), BankName = MyHost.Element("BankAccuont").Element("BankName").Value, BranchNumber = int.Parse(MyHost.Element("BankAccuont").Element("BranchNumber").Value), BranchAddress = MyHost.Element("BankAccuont").Element("BranchAddress").Value, BranchCity = MyHost.Element("BankAccuont").Element("BranchCity").Value } }).ToList(); return(AllMyHost[i]); } catch { return(null); } }