public void AddContract(Contract inputContract)
        {
            Child tempChild = DalTools.GetChild(inputContract.ChildID);

            if (tempChild == null)
            {
                throw new Exception("Child in the contract not found...");
            }

            Nanny tempNanny = DalTools.GetNanny(inputContract.NannyID);

            if (tempNanny == null)
            {
                throw new Exception("Nanny in the contract not found...");
            }

            DataSource.ContractList.Add(inputContract);

            int ContractIdCreator = 0;

            if (DataSource.ContractList.Count == 1)
            {
                ContractIdCreator = 999;
            }
            else
            {
                ContractIdCreator = DataSource.ContractList[DataSource.ContractList.Count - 2].ContID;
            }
            inputContract.ContID = ++ContractIdCreator;
            SaveToXML <List <Contract> >(DataSource.ContractList, ContractsPath);
        }
        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);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// delete a child from database
        /// </summary>
        /// <param name="inputChildId">id of child to delete</param>
        public bool DeleteChild(int inputChildId)
        {
            Child tempChild = DalTools.GetChild(inputChildId);

            if (tempChild == null)
            {
                throw new Exception("Child with the same id not found");
            }
            return(DataSource.ChildsList.Remove(tempChild));
        }
Ejemplo n.º 4
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");
            }
        }
Ejemplo n.º 5
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));
        }
Ejemplo n.º 6
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);
        }
Ejemplo n.º 7
0
        public bool DeleteContract(int inputContractId)
        {
            Contract tempContract = DalTools.GetContract(inputContractId);

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

            return(DataSource.ContractList.Remove(tempContract));
        }
Ejemplo n.º 8
0
        public bool DeleteNanny(int inputNannyId)
        {
            Nanny tempNanny = DalTools.GetNanny(inputNannyId);

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


            return(DataSource.NanniesList.Remove(tempNanny));
        }
        public bool DeleteContract(int inputContractId)
        {
            Contract tempContract = DalTools.GetContract(inputContractId);

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

            bool DeleteIsSuccessful = DataSource.ContractList.Remove(tempContract);

            SaveToXML <List <Contract> >(DataSource.ContractList, ContractsPath);
            return(DeleteIsSuccessful);
        }
        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);
        }
        public bool DeleteNanny(int inputNannyId)
        {
            Nanny tempNanny = DalTools.GetNanny(inputNannyId);

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


            bool DeleteIsSuccessful = DataSource.NanniesList.Remove(tempNanny);

            SaveToXML <List <Nanny> >(DataSource.NanniesList, NanniesPath);
            return(DeleteIsSuccessful);
        }
Ejemplo n.º 12
0
        public void AddContract(Contract inputContract)
        {
            Child tempChild = DalTools.GetChild(inputContract.ChildID);

            if (tempChild == null)
            {
                throw new Exception("Child in the contract not found...");
            }

            Nanny tempNanny = DalTools.GetNanny(inputContract.NannyID);

            if (tempNanny == null)
            {
                throw new Exception("Nanny in the contract not found...");
            }

            inputContract.ContID = ContractIdCreator;
            ContractIdCreator++;

            DataSource.ContractList.Add(inputContract);
        }
 public void AddNanny(Nanny inputNanny)
 {
     DalTools.CheckifExistsId(inputNanny.NannyId);
     DataSource.NanniesList.Add(inputNanny);
     SaveToXML <List <Nanny> >(DataSource.NanniesList, NanniesPath);
 }
 public void AddMom(Mother inputMother)
 {
     DalTools.CheckifExistsId(inputMother.MomID); // ido
     DataSource.MomsList.Add(inputMother);
     SaveToXML <List <Mother> >(DataSource.MomsList, MothersPath);
 }
Ejemplo n.º 15
0
 public void AddMom(Mother inputMother)
 {
     DalTools.CheckifExistsId(inputMother.MomID); // ido
     DataSource.MomsList.Add(inputMother);
 }
Ejemplo n.º 16
0
 public void AddNanny(Nanny inputNanny)
 {
     DalTools.CheckifExistsId(inputNanny.NannyId);
     DataSource.NanniesList.Add(inputNanny);
 }