예제 #1
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");
        }
예제 #2
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");
        }
예제 #3
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");
        }
예제 #4
0
        public void DeleteContract(Contract c)
        {
            DataSource_XML.LoadData("Contracts");                           // load the Contracts file
            XElement temp = ((from e in DataSource_XML.Contracts.Elements() // check if the contract exist - save it in tmp
                              where e.Element("ChildID").Value == c.ChildID
                              select e).FirstOrDefault());

            if (temp == null)
            {
                throw new Exception("This Contract does not exist");
            }
            temp.Remove();
            DataSource_XML.SaveData("Contracts");
        }
예제 #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
        }
예제 #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");
        }
예제 #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
        }
예제 #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");
        }
예제 #9
0
        public void DeleteChild(Child c, bool deleteall = true)
        {
            DataSource_XML.LoadData("Children");                           // load the Children file
            XElement temp = ((from e in DataSource_XML.Children.Elements() // check uf the child exist
                              where e.Element("ID").Value == c.ID
                              select e).FirstOrDefault());

            if (temp == null)
            {
                throw new Exception("This Child does not exist");
            }
            temp.Remove();
            DataSource_XML.SaveData("Children");
            XElement tmpC = ((from con in DataSource_XML.Contracts.Elements() // delete the contract with this child
                              where con.Element("ChildID").Value == c.ID
                              select con).FirstOrDefault());

            if (tmpC != null && deleteall) // deleteall- if the use is to delete and not for update
            {
                DeleteContract(tmpC.XmlToContract());
            }
        }
예제 #10
0
        public void DeleteNanny(Nanny n, bool deleteall = true)
        {
            DataSource_XML.LoadData("Nannys");                           // load the nnanies file
            XElement temp = ((from e in DataSource_XML.Nannys.Elements() //check if the nanny exist - save it in tmp
                              where e.Element("ID").Value == n.ID
                              select e).FirstOrDefault());

            if (temp == null)
            {
                throw new Exception("This Nanny does not exist");
            }
            temp.Remove();
            DataSource_XML.SaveData("Nannys");
            if (deleteall)  // deleteall- if the use is to delete and not for update
            {
                foreach (var item in DataSource_XML.Contracts.Elements())
                {
                    if (item.Element("NannyID").Value == n.ID)
                    {
                        DeleteContract(item.XmlToContract());
                    }
                }
            }
        }
예제 #11
0
        public void DeleteMother(Mother m, bool deleteall = true)
        {
            DataSource_XML.LoadData("Mothers");                           // load the Mothers file
            XElement temp = ((from e in DataSource_XML.Mothers.Elements() // check if the contract exist c
                              where e.Element("ID").Value == m.ID
                              select e).FirstOrDefault());

            if (temp == null)
            {
                throw new Exception("This Mother does not exist");
            }
            temp.Remove();
            DataSource_XML.SaveData("Mothers");
            if (deleteall) // deleteall- if the use is to delete and not for update
            {
                foreach (var item in DataSource_XML.Children.Elements())
                {
                    if (item.Element("MyMotherID").Value == m.ID)
                    {
                        DeleteChild(item.XmlToChild());
                    }
                }
            }
        }