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);
        }
Ejemplo n.º 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");
            }
        }
Ejemplo n.º 3
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 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.º 5
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);
        }