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