Ejemplo n.º 1
0
        /// <summary>
        /// verify if the employer has active contracts, if it is true, we can not delete him
        /// </summary>
        /// <param name="oldEmployer"></param>
        public void DelEmployer(Employer oldEmployer)
        {
            IEnumerable <Contract> verification = from contract in dal.ReturnContracts()
                                                  where contract.employerId == oldEmployer.id && contract.hasBeenSigned
                                                  select contract;

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

            dal.DelEmployer(oldEmployer);
        }