/** * @fn public bool Add(Employee newEmployee) * * @brief Adds a deep copy of newEmployee if it's valid. * * @param newEmployee The new employee to add. * * @return returns true if the specified Employee is valid and was added, false otherwise. */ public bool Add(Employee newEmployee) { if(newEmployee.Validate()) { logger.LogEventAsync("Employee added: " + Environment.NewLine + newEmployee.Details(), this.GetType().Name); employees.Add(newEmployee.DeepCopy()); return true; } else { return false; } }
/** * @fn public bool Modify(int index, Employee newEmployee) * * @brief Replaces the Employee at the index with a deep copy of newEmployee if it's valid. * * @param index the index of the employee to modify. * @param newEmployee The new employee use. * * @throws System.ArgumentOutOfRangeException * index is less than 0.-or-index is equal to or greater than Count. * * @return returns true if the specified Employee is valid and was added, false otherwise. */ public bool Modify(int index, Employee newEmployee) { if(newEmployee.Validate()) { logger.LogEventAsync( "Employee modified from: " + Environment.NewLine + employees[index].Details() + "To: " + Environment.NewLine + newEmployee.Details(), this.GetType().Name); employees[index] = newEmployee.DeepCopy(); return true; } else { return false; } }