Пример #1
0
        public void AddContract(BE.Contract C)
        {//checks that contract does not exist already and the nanny and child do
            XElement root = BasicXML.LoadData();

            if (checkContract(C) == true)
            {
                throw new Exception("Contract already exists");
            }
            bool flage = false;

            foreach (BE.Nanny item in GetListOfNannys())
            {
                if (C.NannyId == item.NannyId)
                {
                    flage = true;
                }
            }
            if (flage == false)
            {
                throw new Exception("Nanny does not exist");
            }
            foreach (BE.Child item in GetListOfChildS())
            {
                if (C.ChildId == item.ChildId)
                {
                    flage = false;
                }
            }
            if (flage == true)
            {
                throw new Exception("Child does not exist");
            }
            foreach (BE.Mother item in GetListOfMotherS())
            {
                if (C.MotherId == item.MotherId)
                {
                    flage = true;
                }
            }
            if (flage == false)
            {
                throw new Exception("Mother does not exist");
            }
            foreach (BE.Contract item in GetListOfContracts())
            {
                if (C.ChildId == item.ChildId)
                {
                    if (item.NannyId == C.NannyId)
                    {
                        flage = false;
                    }
                }
            }
            if (flage == false)
            {
                throw new Exception("Contract already exist");
            }
            root.Add(ExtensionBE.ToXML(C));
            BasicXML.Save(root);
        }
Пример #2
0
        public void AddNanny(BE.Nanny N)
        {//adds nanny to list after checking that he does not exist already
            XElement root = BasicXML.LoadData();

            if (checkNanny(N) == true)
            {
                throw new Exception("nanny already exists");
            }
            root.Add(ExtensionBE.ToXML(N));
            BasicXML.Save(root);
        }
Пример #3
0
        public void AddChild(BE.Child C)
        {//adds child to list after checking that he does not exist already
            XElement root = BasicXML.LoadData();

            if (checkChild(C) == true)
            {
                throw new Exception("Child already exists");
            }
            root.Add(ExtensionBE.ToXML(C));
            BasicXML.Save(root);
        }
Пример #4
0
        public void AddMother(BE.Mother M)
        {//adds mother to list after checking that he does not exist already
            XElement root = BasicXML.LoadData();

            if (checkMother(M) == true)
            {
                throw new Exception("mother already exists");
            }
            root.Add(ExtensionBE.ToXML(M));
            BasicXML.Save(root);
        }
Пример #5
0
        public void ChangeInfoChild(BE.Child C)
        //A function that gets Child after its details have been updated
        //The function finds the Child in the database in the xml file before the update,
        //deletes it from the list and adds the Child after the update
        {
            XElement root = BasicXML.LoadData();
            XElement help;

            help = (from item in root.Elements()
                    where item.Name == "Child"
                    where int.Parse(item.Element("id").Value) == C.ChildId
                    select item).FirstOrDefault();
            help.Remove();
            root.Add(ExtensionBE.ToXML(C));
            BasicXML.Save(root);
        }