public Order SearchOrderById(int id)//get order by id { LoadData(); BranchClass myxml = new BranchClass(); Order order; try { order = (from p in OrderRoot.Elements() where Convert.ToInt32(p.Element("id").Value) == id select new Order(long.Parse(p.Element("id").Value), DateTime.Parse(p.Element("Order_Details").Element("Date").Value), myxml.SearchBranchById(int.Parse(p.Element("Order_Details").Element("Branch").Value)), (BE.kosherLevel)Enum.Parse(typeof(BE.kosherLevel),p.Element("Order_Details").Element("KosherLevel").Value), int.Parse(p.Element("Order_Details").Element("phone").Value))).FirstOrDefault(); } catch { order = null; } return order; }
public IEnumerable<Order> GetAllOrder()//get all orders { LoadData(); BranchClass myxml = new BranchClass(); try { return (from p in OrderRoot.Elements() select new Order(long.Parse(p.Element("id").Value), DateTime.Parse(p.Element("Order_Details").Element("Date").Value), myxml.SearchBranchById(int.Parse(p.Element("Order_Details").Element("Branch").Value)), (BE.kosherLevel)Enum.Parse(typeof(BE.kosherLevel), p.Element("Order_Details").Element("KosherLevel").Value), int.Parse(p.Element("Order_Details").Element("phone").Value))); } catch (Exception ex) { throw new ArgumentNullException("XML Error: The database " + OrderPath + " is empty or corrupted" + "\n" + "Error number" + ex.HResult); } }