示例#1
0
        public void RegisterUser(RegistrationInfo registrationInfo, string profileId)
        {
            Assert.ArgumentNotNullOrEmpty(registrationInfo.Email, "email");
            Assert.ArgumentNotNullOrEmpty(registrationInfo.Password, "password");

            var fullName = Context.Domain.GetFullName(registrationInfo.Email);

            try
            {
                Assert.IsNotNullOrEmpty(fullName, "Can't retrieve full userName");

                var user = User.Create(fullName, registrationInfo.Password);
                user.Profile.Email    = registrationInfo.Email;
                user.Profile.FullName = registrationInfo.FirstName + " " + registrationInfo.LastName;
                user.Profile.Name     = registrationInfo.FirstName;
                user.Profile.SetCustomProperty("LastName", registrationInfo.LastName);

                if (!string.IsNullOrEmpty(profileId))
                {
                    user.Profile.ProfileItemId = profileId;
                }

                user.Profile.Save();
                _pipelineService.RunRegistered(user);
            }
            catch
            {
                _accountTrackerService.TrackRegistrationFailed(registrationInfo.Email);
                throw;
            }

            Login(registrationInfo.Email, registrationInfo.Password);
        }