public void Register(RegisterUserRequest register)
        {
            using (var database = DatabaseFactory.GetDatabase())
            {
                // Let's do this in a transaction, so we cannot register two users
                // with the same name. Seems to be a useful requirement.
                using (var tran = database.GetTransaction())
                {
                    string hashBase64;
                    string saltBase64;

                    cryptoService.CreateHash(register.Password, out hashBase64, out saltBase64);

                    User user = new User()
                    {
                        Name = register.UserName,
                        PasswordHash = hashBase64,
                        PasswordSalt = saltBase64
                    };

                    database.Insert(user);

                    tran.Complete();
                }
            }
        }
 /// <summary>
 /// Converts between Model and DB Entity.
 /// </summary>
 UserIdentity Convert(User user, IList<Claim> claims)
 {
     if (user == null)
     {
         return null;
     }
     return new UserIdentity()
     {
         Id = user.Id,
         Name = user.Name,
         Claims = Convert(claims)
     };
 }