public MembershipUser CreateContact(string firstname, string lastname, string middlename, string email, string username, string password, string passwordQuestion, string passwordAnswer, bool isApproved, out System.Web.Security.MembershipCreateStatus status)
        {
            if (String.IsNullOrEmpty(username))
            {
                throw new ArgumentException("Value cannot be null or empty.", "firstname");
            }
            if (String.IsNullOrEmpty(username))
            {
                throw new ArgumentException("Value cannot be null or empty.", "lastname");
            }
            if (String.IsNullOrEmpty(email))
            {
                throw new ArgumentException("Value cannot be null or empty.", "email");
            }
            if (String.IsNullOrEmpty(username))
            {
                throw new ArgumentException("Value cannot be null or empty.", "userName");
            }
            if (String.IsNullOrEmpty(password))
            {
                throw new ArgumentException("Value cannot be null or empty.", "password");
            }

            int count;

            FindUsersByEmail(email, 0, 1, out count);
            if (count == 0)
            {
                FindUsersByName(username, 0, 1, out count);
            }
            else
            {
                status = MembershipCreateStatus.DuplicateEmail;
                return(null);
            }

            if (count == 0)
            {
                System.Net.Mail.MailAddress address = new System.Net.Mail.MailAddress(email);
                Contact contact = null;
                using (var Entities = Repository)
                {
                    var contacts = Entities.ContactEmails_v1_0.Where(e => e.Email_v1_0.formattedEmailAddress == email);
                    if (contacts.Count() == 1)
                    {
                        status = MembershipCreateStatus.DuplicateEmail;
                        return(null);
                    }
                    else
                    {
                        contact = new Contacts_v1_0
                        {
                            firstName           = firstname,
                            lastName            = lastname,
                            middleName          = middlename,
                            givenName           = firstname,
                            firstPartOfLastName = lastname.GetCharLeftPart(),
                            createDate          = DateTime.Now
                        };
                        Email_v1_0 mail = new Email_v1_0
                        {
                            formattedEmailAddress = address.Address,
                            domainName            = address.Host.Split('.')[0],
                            extension             = address.Host.Split('.')[1],
                            localpart             = address.User,
                            emailTypeId           = 2 //TODO:Detect
                        };
                        ContactEmails_v1_0 contactMail = new ContactEmails_v1_0
                        {
                            Contacts_v1_0 = contact,
                            Email_v1_0    = mail
                        };

                        return(CreateUser(username, password, email, passwordQuestion, passwordAnswer, isApproved, contact, out status));
                    }
                }
            }
            else
            {
                status = MembershipCreateStatus.DuplicateUserName;
                return(null);
            }
        }
        public MembershipUser CreateContact(string firstname, string lastname, string middlename, string email, string username, string password, string passwordQuestion, string passwordAnswer, bool isApproved, out System.Web.Security.MembershipCreateStatus status)
        {
            if (String.IsNullOrEmpty(username)) throw new ArgumentException("Value cannot be null or empty.", "firstname");
            if (String.IsNullOrEmpty(username)) throw new ArgumentException("Value cannot be null or empty.", "lastname");
            if (String.IsNullOrEmpty(email)) throw new ArgumentException("Value cannot be null or empty.", "email");
            if (String.IsNullOrEmpty(username)) throw new ArgumentException("Value cannot be null or empty.", "userName");
            if (String.IsNullOrEmpty(password)) throw new ArgumentException("Value cannot be null or empty.", "password");
    
            int count;
            FindUsersByEmail(email, 0, 1, out count);
            if (count == 0)
                FindUsersByName(username, 0, 1, out count);
            else
            {
                status = MembershipCreateStatus.DuplicateEmail;
                return null;
            }

            if (count == 0)
            {
                System.Net.Mail.MailAddress address = new System.Net.Mail.MailAddress(email);
                Contact contact = null;
                using (var Entities = Repository)
                {
                    var contacts = Entities.ContactEmails_v1_0.Where(e => e.Email_v1_0.formattedEmailAddress == email);
                    if (contacts.Count() == 1)
                    {
                        status = MembershipCreateStatus.DuplicateEmail;
                        return null;
                    }
                    else
                    {
                        contact = new Contacts_v1_0
                        {
                            firstName = firstname,
                            lastName = lastname,
                            middleName = middlename,
                            givenName = firstname,
                            firstPartOfLastName = lastname.GetCharLeftPart(),
                            createDate = DateTime.Now
                        };
                        Email_v1_0 mail = new Email_v1_0
                        {
                            formattedEmailAddress = address.Address,
                            domainName = address.Host.Split('.')[0],
                            extension = address.Host.Split('.')[1],
                            localpart = address.User,
                            emailTypeId = 2 //TODO:Detect
                        };
                        ContactEmails_v1_0 contactMail = new ContactEmails_v1_0
                        {
                            Contacts_v1_0 = contact,
                            Email_v1_0 = mail
                        };

                        return CreateUser(username, password, email, passwordQuestion, passwordAnswer, isApproved, contact, out status);
                    }
                }
            }
            else
            {
                status = MembershipCreateStatus.DuplicateUserName;
                return null;
            }
              
        }