// admin and testing functions
        public void CreatePersonForUser(Guid guid, string sponsor)
        {
            string first = null;
            string last = null;
            using (var tudb = new Trips4.Data.Models.TRIPS_UserEntities())
            {
                var found = tudb.GetUserById(guid).FirstOrDefault();
                if (found == null)
                {
                    throw new Exception("User not found " + guid.ToString());
                }
                Debug.Assert(guid == found.UserId.Value);

                first = found.FirstName ?? string.Empty;
                last = found.LastName ?? string.Empty;
            }
            using (var tdb = new Trips4.Data.Models.TRIPSEntities())
            {
                var pid = new ObjectParameter("PersonID", 0);
                tdb.CreatePerson(guid, pid, first, last, sponsor);
            }
        }
        public Person GetUserByID(Guid guid, bool loadRoles)
        {
            var person = new Person();

            // get Person data from Trips
            using (var tdb = new Trips4.Data.Models.TRIPSEntities())
            {
                var found = tdb.GetPersonById(null, guid).FirstOrDefault();
                if (found == null)
                {
                    Logger.Info("Person not found (so he cannot sponsor projects) " + guid.ToString());
                }
                else
                {
                    Debug.Assert(found.PersonGUID == guid);
                    person.profile.PersonID = found.PersonID;
                    person.HasProjects = found.SponsorsProject ?? false;
                    person.SponsorOrganizationId = found.SponsorOrganizationId ?? 0;
                    person.SponsorOrganizationName = found.SponsorOrganization;
                }
                if (person.HasProjects)
                {
                    person.SponsoredProjectVersionIds.AddRange(tdb.GetPersonsProjectVersionIds(person.profile.PersonID).Select(x => x.Value));
                }
            }

            // get profile data from Trips_User
            using (var tudb = new Trips4.Data.Models.TRIPS_UserEntities())
            {
                var found = tudb.GetUserById(guid).FirstOrDefault();
                if (found == null)
                {
                    throw new Exception("User not found " + guid.ToString());
                }
                Debug.Assert(guid == found.UserId.Value);

                person.profile.PersonGUID = found.UserId.Value;
                person.profile.FirstName = found.FirstName;
                person.profile.LastName = found.LastName;
                person.profile.Phone = found.PrimaryContact;
                person.profile.RecoveryEmail = found.LoweredEmail; // TODO: is this true?
                person.profile.UserName = found.UserName;
            }

            // get roles from RoleProvider
            if (loadRoles)
            {
                var roles = Roles.GetRolesForUser(person.profile.UserName);
                person.profile.Roles.AddRange(roles);
            }

            return person;
        }