Exemplo n.º 1
0
        /// <summary>
        /// verificate if the employee has actived contracts, if it is true, it we can not delete him
        /// </summary>
        /// <param name="oldEmployee"></param>
        public void DelEmployee(Employee oldEmployee)
        {
            IEnumerable <Contract> verification = from contract in dal.ReturnContracts()
                                                  where contract.employeeId == oldEmployee.id && contract.hasBeenSigned
                                                  select contract;

            if (verification.Any(contract => contract.endWork < DateTime.Now))
            {
                throw new Exception("We can not delete employee because he has actived contracts");
            }

            dal.DelEmployee(oldEmployee);
        }