private User CreateUserFromProfile(OpenIdProfile profile)
        {
            if (_repository.All<OpenIdentifier>().ByIdentifier(profile.Identifier) != null)
                throw new InvalidOperationException(
                    "The openId '{0}' is already associated with another user.".ToFormat(profile.Identifier));

            var openIdentifier = new OpenIdentifier
                                     {
                                         Identifier = profile.Identifier,
                                         IsPrimary = true
                                     };

            var user = new User
                           {
                               BirthDate = profile.Birthday,
                               DateCreated = DateTime.Now,
                               DisplayName = (!string.IsNullOrEmpty(profile.DisplayName)
                                                ? profile.DisplayName : profile.PreferredUserName) + "",
                               Location =
                                   (profile.Address != null
                                       ? (profile.Address.Locality + " " + profile.Address.Region).Trim()
                                       : string.Empty) + "",
                               Email =
                                   (string.IsNullOrEmpty(profile.VerifiedEmail)
                                       ? profile.Email
                                       : profile.VerifiedEmail) + "",
                               LastVisit = DateTime.Now,
                               Photo = profile.Photo + "",
                               PreferredUserName = profile.PreferredUserName + "",
                               RealName = (profile.Name != null ? profile.Name.FormattedName : string.Empty) + "",
                               Reputation = 0
                           };

            if (user.DisplayName.Trim() == string.Empty)
                user.DisplayName = "Uknown";

            using (var tx = _repository.BeginTransaction())
            {
                _repository.Save(user);

                openIdentifier.UserId = user.Id;

                _repository.Save(openIdentifier);

                _repository.Save(new ActionItem{Action = ActionType.Registered, DateCreated = DateTime.Now, UserId = user.Id});

                tx.Commit();
            }

            Rpx.Map(profile.Identifier, user.Id.ToString(System.Globalization.CultureInfo.CurrentCulture));

            return user;
        }
 public void UpdateUser(User user)
 {
     using (_repository.OpenSession())
     {
         using (var tx = _repository.BeginTransaction())
         {
             _repository.Update(user);
             tx.Commit();
         }
     }
 }
 public SolutionViewModel(Solution solution, User user)
 {
     _solution = solution;
     _user = user;
 }
 public UserInfoViewModel(User user)
 {
     _user = user;
 }
        public UserProfileViewModel(User user, int currentUserId, DateTime? lastActivity)
        {
            _user = user;
            _currentUserId = currentUserId;
            _lastActivity = lastActivity;

            var badgeViewModels = new List<BadgeViewModel>();
            var groupedBadges = user.Badges.GroupBy(x => x.Id);
            foreach (var badge in groupedBadges)
            {
                badgeViewModels.Add(new BadgeViewModel(badge));
            }

            Badges = badgeViewModels;
        }