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 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"); } }
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); }
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); }