/* [Randy] Add new registration entry */
        public string addRegistration(registration reg, user user, membership mem)
        {
            /*int type, string firstname, string lastname, string affiliationName, bool registrationstatus, bool hasapplied, bool acceptancestatus*/
            try
            {
                using (conferenceadminContext context = new conferenceadminContext())
                {
                    address address = new address();
                    context.addresses.Add(address);

                    //encryption
                    var userPassword = mem.password;

                    mem.password = Security.GetSHA1HashData(mem.password);

                    //end encryption
                    mem.emailConfirmation = true;
                    mem.deleted = false;
                    context.memberships.Add(mem);

                    context.SaveChanges();

                    user.addressID = address.addressID;
                    user.membershipID = mem.membershipID;
                    user.registrationStatus = "Accepted";
                    user.hasApplied = true;
                    user.acceptanceStatus = "Accepted";
                    user.title = "";
                    user.phone = "";
                    user.userFax = "";
                    user.deleted = false;
                    context.users.Add(user);
                    context.SaveChanges();

                    reg.userID = user.userID;
                    reg.paymentID = 1;
                    reg.byAdmin = true;
                    reg.deleted = false;
                    context.registrations.Add(reg);

                    context.SaveChanges();

                    try { sendEmailConfirmation(mem.email, userPassword); }

                    catch (Exception ex)
                    {
                        Console.Write("AdminManager.ConfirmationEmail error " + ex);
                        return null;
                    }

                    return reg.registrationID + "," + user.userTypeID;
                }
            }
            catch (Exception ex)
            {
                Console.Write("AdminManager.addRegistration error " + ex);
                return null;
            }
        }
        public SponsorQuery addSponsor(SponsorQuery x)
        {
            try
            {
                using (conferenceadminContext context = new conferenceadminContext())
                {
                    address address = new address();
                    address.city = x.city;
                    address.country = x.country;
                    address.state = x.state;
                    address.zipcode = x.zipcode;
                    address.line1 = x.line1;
                    address.line2 = x.line2;
                    context.addresses.Add(address);
                    context.SaveChanges();

                    user user = new user();
                    user.membershipID = 1;
                    user.firstName = x.firstName;
                    user.lastName = x.lastName;
                    user.userFax = x.userFax;
                    user.phone = x.phone;
                    user.addressID = address.addressID;
                    user.affiliationName = x.company;
                    user.userTypeID = 7;
                    user.deleted = false;
                    context.users.Add(user);
                    context.SaveChanges();

                    payment payment2 = new payment();
                    payment2.paymentTypeID = 1;
                    payment2.deleted = false;
                    payment2.creationDate = DateTime.Now;
                    context.payments.Add(payment2);
                    context.SaveChanges();

                    paymentbill bill = new paymentbill();
                    bill.AmountPaid = (double)x.amount;
                    bill.paymentID = payment2.paymentID;
                    bill.methodOfPayment = x.method;
                    bill.transactionid = x.transactionID;
                    bill.completed = true;
                    bill.quantity = (int)(x.amount * 100);
                    bill.deleted = false;
                    bill.date = DateTime.Now;
                    context.paymentbills.Add(bill);
                    context.SaveChanges();

                    sponsor2 sponsor = new sponsor2();
                    sponsor.userID = user.userID;
                    sponsor.emailInfo = x.email;
                    sponsor.logo = x.logo;
                    sponsor.sponsorType = x.sponsorType;
                    sponsor.totalAmount = x.amount;
                    sponsor.deleted = false;
                    sponsor.byAdmin = true;
                    sponsor.active = true;
                    sponsor.paymentID = payment2.paymentID;

                    context.sponsor2.Add(sponsor);
                    context.SaveChanges();
                    x.sponsorID = sponsor.sponsorID;
                    x.addressID = address.addressID;
                    x.byAdmin = true;
                    return x;
                }

            }
            catch (Exception ex)
            {
                Console.Write("AdminManager.addSponsor error " + ex);
                return null;
            }
        }
        public bool createUser(user user, membership member, address address)
        {
            try
            {
                string key = generateEmailConfirmationKey();
                using (conferenceadminContext context = new conferenceadminContext())
                {
                    //code for password encryption

                    var encrpPass = Security.GetSHA1HashData(member.password);
                    member.password = encrpPass;

                    //end password encryption
                    member.deleted = false;
                    member.emailConfirmation = false;
                    member.deleted = false;
                    member.confirmationKey = key;
                    context.memberships.Add(member);
                    context.SaveChanges();
                    context.addresses.Add(address);
                    context.SaveChanges();

                    user.addressID = address.addressID;
                    user.membershipID = member.membershipID;
                    user.acceptanceStatus = "Pending";
                    user.deleted = false;
                    user.hasApplied = false;
                    user.registrationStatus = "Pending";
                    user.evaluatorStatus = user.evaluatorStatus;

                    context.users.Add(user);
                    context.SaveChanges();

                    if (user.userTypeID == 1)
                    {
                        minor minor = new minor();
                        minor.authorizationStatus = false;
                        minor.deleted = false;
                        minor.userID = user.userID;
                        context.minors.Add(minor);
                        context.SaveChanges();

                    }
                    else if (user.userTypeID == 7)
                    {
                        sponsor2 sponsor = new sponsor2();

                        sponsor.deleted = false;
                        sponsor.userID = user.userID;
                        sponsor.active = false;
                        sponsor.sponsorType = 5;
                        sponsor.byAdmin = false;
                        sponsor.active = false;
                        sponsor.totalAmount = 0;

                        payment payment2 = new payment();
                        payment2.paymentTypeID = 1;
                        payment2.deleted = false;
                        payment2.creationDate = DateTime.Now;
                        context.payments.Add(payment2);

                        context.SaveChanges();
                        sponsor.paymentID = payment2.paymentID;
                        context.sponsor2.Add(sponsor);
                        context.SaveChanges();

                    }
                    else if (user.userTypeID == 6)
                    {
                        companion companion = new companion();
                        companion.deleted = false;
                        companion.userID = user.userID;
                        companion.companionKey = "Companion "+ user.userID + generateEmailConfirmationKey().Substring(0, 9);
                        context.companions.Add(companion);
                        context.SaveChanges();

                    }

                    try { sendEmailConfirmation(member.email, member.confirmationKey); }

                    catch (Exception ex)
                    {
                        Console.Write("SignUpManager.NewConfirmationEmail error " + ex);
                        return false;
                    }

                    return true;

                }

            }
            catch (Exception ex)
            {
                Console.Write("SignUpManager.creatingUser error " + ex);
                return false;
            }
        }