//end of the auxiliar methods //---------------------------------------------// // Employee methods /// <summary> /// verifications that throw exceptions: /// 1)if the employee is under age 18 /// 2)if the employee has criminal record /// 3)if the employee is a student /// 4)if the specialization does not exist /// /// </summary> /// <param name="newEmployee"></param> public void AddEmployee(Employee newEmployee) { if (newEmployee.id < 0) { throw new Exception("Employee ID cannot be a negative number."); } if (newEmployee.age < 18) { throw new Exception("Employee is underage."); } if (newEmployee.criminalRecord) { throw new Exception("Employee has a criminal record."); } if (newEmployee.education == Education.student) { throw new Exception("We can not add students"); } if (!ReturnSpecializations(s => newEmployee.specNumber == s.specializationNumber).Any()) { throw new Exception("A specialization with this number doesn't exist."); } if (!dal.returnAllBranches(bAcc => bAcc.bankNumber == newEmployee.bankAccount.bankNumber).Any()) { throw new Exception("Bank doesn`t exist"); } if (!dal.returnAllBranches(bAcc => bAcc.branchNumber == newEmployee.bankAccount.branchNumber).Any()) { throw new Exception("Banks branch doesn`t exist"); } dal.AddEmployee(newEmployee); }