public bool DeleteById(int id)
 {
     using (var context = new PRToolsEntities())
     {
         var documentToDelete = context.Documents.FirstOrDefault(x => x.DocumentId == id);
         if (documentToDelete == null)
             return false;
         context.DeleteObject(documentToDelete);
         context.SaveChanges();
         return true;
     }
 }
        public void Delete(int customerId)
        {
            using (var context = new PRToolsEntities())
            {
                Customer customerEntity =
                    context.Customers.Include("Addresses").FirstOrDefault(x => x.CustomerId == customerId);
                if (customerEntity == null)
                    throw new ObjectNotFoundException();

                List<Address> addressEntities = customerEntity.Addresses.ToList();
                foreach (Address addressEntity in addressEntities)
                {
                    context.DeleteObject(addressEntity);
                }

                List<Contact> contactEntities = customerEntity.Contacts.ToList();
                foreach (Contact contactEntity in contactEntities)
                {
                    context.DeleteObject(contactEntity);
                }

                context.DeleteObject(customerEntity);
                context.SaveChanges();
            }
        }