Exemple #1
0
        public Employee DeleteEmployee(Employee employee)
        {
            if (employee == null)
            {
                throw new NullReferenceException("Employee object cannot be null.");
            }

            if (employee.Id < 1)
            {
                throw new ArgumentException("Employee ID is not defined for deletion.");
            }

            var delEmp = _repository.GetBy(p => p.Id == employee.Id).FirstOrDefault();

            if (delEmp != null)
            {
                _repository.Delete(delEmp);
                _repository.SaveAll();
            }

            return(delEmp);
        }