public static void DeleteApplicantsAndDetails(int[] applicantIds, GranaDataDataContext context)
        {
            //Delete Applications for these applicants
            List<Application> applications =
                context.Applications.Where(a => applicantIds.Contains(a.ApplicantId)).ToList();
            int[] applicationIds = applications.Select(a => a.ApplicationId).ToArray();

            //Delete Applications
            DataBaseDeleteApplications.DataBaseDeleteApplicationsAndDetails(applicationIds, context);

            //Delete Employments
            List<Employment> employments = context.Employments.Where(e => applicantIds.Contains(e.ApplicantId)).ToList();
            context.Employments.DeleteAllOnSubmit(employments);

            //Delete BankCards
            List<BankCard> bankCards = context.BankCards.Where(c => applicantIds.Contains(c.ApplicantId)).ToList();
            context.BankCards.DeleteAllOnSubmit(bankCards);

            //Delete BankAccount
            List<BankAccount> bankAccounts = context.BankAccounts.Where(a => applicantIds.Contains(a.ApplicantId)).ToList();
            context.BankAccounts.DeleteAllOnSubmit(bankAccounts);

            //Delete Addresses

            List<Address> addresses = context.Addresses.Where(a => applicantIds.Contains(a.ApplicantId)).ToList();
            context.Addresses.DeleteAllOnSubmit(addresses);

            //Delete Applicants
            List<Applicant> applicants = context.Applicants.Where(a => applicantIds.Contains(a.ApplicantId)).ToList();
            context.Applicants.DeleteAllOnSubmit(applicants);

            context.SubmitChanges();
        }
        public static void DataBaseDeleteApplicationsAndDetails(int[] applicationIds, GranaDataDataContext context)
        {
            List<Application> applications = context.Applications.Where(a => applicationIds.Contains(a.ApplicationId)).ToList();

            //Delete Reasons
            List<ReasonLog> reasons = context.ReasonLogs.Where(r => applicationIds.Contains(r.ApplicationId)).ToList();
            context.ReasonLogs.DeleteAllOnSubmit(reasons);

            //Delete Notes
            List<Note> notes = context.Notes.Where(n => applicationIds.Contains(n.ApplicationId)).ToList();
            context.Notes.DeleteAllOnSubmit(notes);

            //Delete Documents
            List<Document> documents = context.Documents.Where(d => applicationIds.Contains(d.ApplicationId)).ToList();
            context.Documents.DeleteAllOnSubmit(documents);

            //Delete Contacts
            List<Contact> contacts = context.Contacts.Where(c => applicationIds.Contains(c.ApplicationId)).ToList();
            context.Contacts.DeleteAllOnSubmit(contacts);

            //Delete applications
            context.Applications.DeleteAllOnSubmit(applications);

            context.SubmitChanges();
        }
        public static void DeleteExistingApplicants(List<Applicant> applicants, GranaDataDataContext context)
        {
            int[] applicantIds = applicants.Select(a => a.ApplicantId).ToArray();

            DeleteApplicantsAndDetails(applicantIds, context);
        }