public void AddChild(Child inputChild)
        {
            DalTools.CheckifExistsId(inputChild.ChildID); // ido
            Mother tempMom = DalTools.GetMother(inputChild.ChildMomID);

            if (tempMom == null)
            {
                throw new Exception("The child's mother does not exist in the system, please add the mother before");
            }

            XElement ChildID    = new XElement("ChildID", inputChild.ChildID);
            XElement ChildMomID = new XElement("ChildMomID", inputChild.ChildMomID);
            XElement Name       = new XElement("Name", inputChild.ChildName);

            XElement YearDate  = new XElement("YearDate", inputChild.ChildAge.Year);
            XElement MonthDate = new XElement("MonthDate", inputChild.ChildAge.Month);
            XElement DayDate   = new XElement("DayDate", inputChild.ChildAge.Day);
            XElement Age       = new XElement("Age", DayDate, MonthDate, YearDate);

            XElement ChildIsSpecialNeeds      = new XElement("IsSpecialNeeds", inputChild.ChildIsSpecialNeeds);
            XElement ChildTypesOfSpecialNeeds = new XElement("TypesOfSpecialNeeds", inputChild.ChildTypesOfSpecialNeeds);
            XElement IsHaveNanny = new XElement("IsHaveNanny", inputChild.IsHaveNanny);

            XElement Child = new XElement("Child", ChildID, ChildMomID, Name, Age, ChildIsSpecialNeeds, ChildTypesOfSpecialNeeds, IsHaveNanny);

            ChildrenXmlRoot.Add(Child);
            ChildrenXmlRoot.Save(ChildrenPath);
        }
Пример #2
0
        public static void CheckifExistsId(int idForCheck) // Ido
        {
            Child  tempChild  = DalTools.GetChild(idForCheck);
            Mother tempMother = DalTools.GetMother(idForCheck);
            Nanny  tempNanny  = DalTools.GetNanny(idForCheck);

            if (tempNanny != null || tempMother != null || tempChild != null)
            {
                throw new Exception("Error, Same id already exists");
            }
        }
Пример #3
0
        public bool DeleteMom(int inputMomId)
        {
            Mother tempMother = DalTools.GetMother(inputMomId);

            if (tempMother == null)
            {
                throw new Exception("Mother with the same id not found...");
            }

            return(DataSource.MomsList.Remove(tempMother));
        }
Пример #4
0
        /// <summary>
        /// add a child to database
        /// </summary>
        /// <param name="inputChild">child to add</param>
        public void AddChild(Child inputChild)
        {
            DalTools.CheckifExistsId(inputChild.ChildID); // ido
            Mother tempMom = DalTools.GetMother(inputChild.ChildMomID);

            if (tempMom == null)
            {
                throw new Exception("The child's mother does not exist in the system, please add the mother before");
            }
            DataSource.ChildsList.Add(inputChild);
        }
        public bool DeleteMom(int inputMomId)
        {
            Mother tempMother = DalTools.GetMother(inputMomId);

            if (tempMother == null)
            {
                throw new Exception("Mother with the same id not found...");
            }

            bool DeleteIsSuccessful = DataSource.MomsList.Remove(tempMother);

            SaveToXML <List <Mother> >(DataSource.MomsList, MothersPath);
            return(DeleteIsSuccessful);
        }