public void Add(ChatUserIdentity identity)
 {
     _identities.Add(identity);
     if (identity.User != null)
     {
         identity.User.Identities.Add(identity);
     }
 }
        private ChatUser AddUser(string userName, string providerName, string identity, string email)
        {
            if (!IsValidUserName(userName))
            {
                throw new InvalidOperationException(String.Format(LanguageResources.UserInvalidName, userName));
            }

            EnsureProviderAndIdentityAvailable(providerName, identity);

            // This method is used in the auth workflow. If the username is taken it will add a number
            // to the user name.
            if (UserExists(userName))
            {
                var usersWithNameLikeMine = _repository.Users.Count(u => u.Name.StartsWith(userName));
                userName += usersWithNameLikeMine;
            }

            var user = new ChatUser
            {
                Name = userName,
                Status = (int)UserStatus.Active,
                Hash = email.ToMD5(),
                Id = Guid.NewGuid().ToString("d"),
                LastActivity = DateTime.UtcNow,
                IsAdmin = IsFirstUser()
            };

            var chatUserIdentity = new ChatUserIdentity
            {
                User = user,
                Email = email,
                Identity = identity,
                ProviderName = providerName
            };

            _repository.Add(user);
            _repository.Add(chatUserIdentity);
            _repository.CommitChanges();

            return user;
        }
 public void Remove(ChatUserIdentity identity)
 {
     _identities.Remove(identity);
 }
 public void Remove(ChatUserIdentity identity)
 {
     _db.Identities.Remove(identity);
     _db.SaveChanges();
 }
 public void Add(ChatUserIdentity identity)
 {
     _db.Identities.Add(identity);
     _db.SaveChanges();
 }