//public void Update(IContract contract)
        //{
        //    using (var repository = new ContractRepository())
        //    {
        //        var entity = Mapper.Mapper.DTOtoEntity(contract);
        //        repository.Attach(entity);
        //        repository.SaveChanges();
        //    }
        //}

        public IContract CloseContract(ITerminateableContract contract, DateTime closeDate)
        {
            if (contract.ContractCloseDate == null)
            {
                contract.Terminate(closeDate);
                using (var repository = new ContractRepository())
                {
                    var entity = Mapper.Mapper.DTOtoEntity(contract);
                    repository.Attach(entity);
                    repository.SaveChanges();
                }
                return(GetContracts(x => x.Id == contract.Id).FirstOrDefault());
            }
            else
            {
                return(null);
            }
        }