Exemplo n.º 1
0
        public IEnumerable <Child> GetChildsListByMother(Mother m)
        {
            XElement     root   = DataSource_XML.Children;
            List <Child> result = new List <Child>();

            result = (from c in root.Elements("child")              //for each child
                      where m.ID == c.Element("MyMotherID").Value   //if its mother id is the same to the mother id that we want
                      select DAL_Converts.XmlToChild(c)).ToList();  //add this child
            return(result.AsEnumerable());
        }
Exemplo n.º 2
0
        public void UpdateNanny(Nanny n)
        {
            DataSource_XML.LoadData("Nannys");
            XElement temp = ((from e in DataSource_XML.Nannys.Elements() //check if the nanny exist
                              where e.Element("ID").Value == n.ID
                              select e).FirstOrDefault());

            if (temp == null)
            {
                throw new Exception("This Nanny not exist");
            }
            temp.ReplaceWith(DAL_Converts.NannyToXml(n)); // replace between the nanny details
            DataSource_XML.SaveData("Nannys");
        }
Exemplo n.º 3
0
        public void UpdateMother(Mother m)
        {
            DataSource_XML.LoadData("Mothers");
            XElement temp = ((from e in DataSource_XML.Mothers.Elements() // check if the mother exist
                              where e.Element("ID").Value == m.ID
                              select e).FirstOrDefault());

            if (temp == null)
            {
                throw new Exception("This Mother not exist");
            }
            temp.ReplaceWith(DAL_Converts.MotherToXml(m));// replace between the mother details
            DataSource_XML.SaveData("Mothers");
        }
Exemplo n.º 4
0
        public void UpdateContract(Contract c)
        {
            DataSource_XML.LoadData("Contracts");
            XElement temp = ((from e in DataSource_XML.Contracts.Elements() // check if the contract exist
                              where e.Element("ChildID").Value == c.ChildID
                              select e).FirstOrDefault());

            if (temp == null)
            {
                throw new Exception("This Contract not exist");
            }
            temp.ReplaceWith(DAL_Converts.ContractToXml(c)); // replace between the contract details
            DataSource_XML.SaveData("Contracts");
        }
Exemplo n.º 5
0
        public void AddNanny(Nanny n)
        {
            DataSource_XML.LoadData("Nannys");                           // load the nannies file
            XElement temp = ((from e in DataSource_XML.Nannys.Elements() // check if the Nanny already exist
                              where e.Element("ID").Value == n.ID
                              select e).FirstOrDefault());

            if (temp != null)
            {
                throw new Exception("This Nanny already exist");
            }

            DataSource_XML.Nannys.Add(DAL_Converts.NannyToXml(n));
            DataSource_XML.SaveData("Nannys"); // save the file
        }
Exemplo n.º 6
0
        public void AddChild(Child c)
        {
            DataSource_XML.LoadData("Children");                           //load the Children file
            XElement temp = ((from e in DataSource_XML.Children.Elements() // check if the child is exists
                              where e.Element("ID").Value == c.ID
                              select e).FirstOrDefault());

            if (temp != null)
            {
                throw new Exception("This Child already exist");
            }

            DataSource_XML.Children.Add(DAL_Converts.ChildToXml(c));//
            DataSource_XML.SaveData("Children");
        }
Exemplo n.º 7
0
        public void AddContract(Contract c)
        {
            DataSource_XML.LoadData("Contracts");                           //load the contract file
            XElement temp = ((from e in DataSource_XML.Contracts.Elements() // check if there is contract for this child
                              where e.Element("ChildID").Value == c.ChildID
                              select e).FirstOrDefault());

            if (temp != null)
            {
                throw new Exception("Cannot add another Contract to same child");
            }
            XElement contract = DAL_Converts.ContractToXml(c);

            contract.Element("ContractNumber").Value = (getContractNumber() + 1).ToString(); // add the new contract number
            DataSource_XML.Contracts.Add(contract);
            DataSource_XML.SaveData("Contracts");                                            // save the file
        }
Exemplo n.º 8
0
        public void AddMother(Mother m)
        {
            DataSource_XML.LoadData("Mothers"); // load the file
            if (DataSource_XML.Mothers == null) // if there isno mother that saved
            {
                DataSource_XML.Mothers.Add(DAL_Converts.MotherToXml(m));
                DataSource_XML.Mothers.Save(DataSource_XML.MotherXml);
            }
            XElement temp = ((from e in DataSource_XML.Mothers.Elements()// check if the Mother already exist
                              where e.Element("ID").Value == m.ID
                              select e).FirstOrDefault());

            if (temp != null)
            {
                throw new Exception("This Mother already exist");
            }

            DataSource_XML.Mothers.Add(DAL_Converts.MotherToXml(m));
            DataSource_XML.SaveData("Mothers");
        }