public void DeleteUser(string name)
        {
            try
            {
                using (PartyEntities context = new PartyEntities(this.connectionString))
                {
                    User user =
                        (from u in context.Users
                         where (u.Name == name)
                         select u).First();

                    if (user != null)
                    {
                        context.DeleteObject(user);
                        context.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                if (ex is UpdateException)
                {
                    throw ex.InnerException;
                }
                throw;
            }
        }
        public void DeleteContact(int id)
        {
            try
            {
                using (PartyEntities context = new PartyEntities(this.connectionString))
                {
                    Contact contact =
                        (from ct in context.Contacts
                         where (ct.Id == id)
                         select ct).First();

                    if (contact != null)
                    {
                        context.DeleteObject(contact);
                        context.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                if (ex is UpdateException)
                {
                    throw ex.InnerException;
                }
                throw;
            }
        }
        public void DeletePartyContact(int partyId, int contactId)
        {
            try
            {
                using (PartyEntities context = new PartyEntities(this.connectionString))
                {
                    PartyContact partyContact =
                        (from pc in context.PartyContacts
                         where (pc.PartyId == partyId && pc.ContactId == contactId)
                         select pc).First();

                    if (partyContact != null)
                    {
                        context.DeleteObject(partyContact);
                        context.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                if (ex is UpdateException)
                {
                    throw ex.InnerException;
                }
                throw;
            }
        }
        public void DeleteParty(int id)
        {
            try
            {
                using (PartyEntities context = new PartyEntities(this.connectionString))
                {
                    using (TransactionScope txnScope = new TransactionScope(TransactionScopeOption.Required))
                    {
                        Party party =
                            (from p in context.Parties
                             where (p.Id == id)
                             select p).First();

                        if (party != null)
                        {
                            var partyContacts =
                                from partyContact in context.PartyContacts
                                where (partyContact.PartyId == id)
                                select partyContact;

                            foreach (PartyContact toRemove in partyContacts)
                            {
                                context.DeleteObject(toRemove);
                                context.SaveChanges();
                            }

                            context.DeleteObject(party);

                            context.SaveChanges();
                            context.AcceptAllChanges();
                            txnScope.Complete();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                if (ex is UpdateException)
                {
                    throw ex.InnerException;
                }
                throw;
            }
        }
        public void DeleteUser(string name)
        {
            try
            {
                using (PartyEntities context = new PartyEntities(this.connectionString))
                {

                    User user =
                        (from u in context.Users
                         where (u.Name == name)
                         select u).First();

                    if (user != null)
                    {
                        context.DeleteObject(user);
                        context.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                if (ex is UpdateException) { throw ex.InnerException; }
                throw;
            }
        }
        public void DeletePartyContact(int partyId, int contactId)
        {
            try
            {
                using (PartyEntities context = new PartyEntities(this.connectionString))
                {

                    PartyContact partyContact =
                       (from pc in context.PartyContacts
                        where (pc.PartyId == partyId && pc.ContactId == contactId)
                        select pc).First();

                    if (partyContact != null)
                    {
                        context.DeleteObject(partyContact);
                        context.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                if (ex is UpdateException) { throw ex.InnerException; }
                throw;
            }
        }
        public void DeleteParty(int id)
        {
            try
            {
                using (PartyEntities context = new PartyEntities(this.connectionString))
                {
                    using (TransactionScope txnScope = new TransactionScope(TransactionScopeOption.Required))
                    {
                        Party party =
                            (from p in context.Parties
                             where (p.Id == id)
                             select p).First();

                        if (party != null)
                        {
                            var partyContacts =
                                from partyContact in context.PartyContacts
                                where (partyContact.PartyId == id)
                                select partyContact;

                            foreach (PartyContact toRemove in partyContacts)
                            {
                                context.DeleteObject(toRemove);
                                context.SaveChanges();
                            }

                            context.DeleteObject(party);

                            context.SaveChanges();
                            context.AcceptAllChanges();
                            txnScope.Complete();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                if (ex is UpdateException) { throw ex.InnerException; }
                throw;
            }
        }
        public void DeleteContact(int id)
        {
            try
            {
                using (PartyEntities context = new PartyEntities(this.connectionString))
                {

                    Contact contact =
                        (from ct in context.Contacts
                         where (ct.Id == id)
                         select ct).First();

                    if (contact != null)
                    {
                        context.DeleteObject(contact);
                        context.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                if (ex is UpdateException) { throw ex.InnerException; }
                throw;
            }
        }