Beispiel #1
0
        /// <summary>
        /// Finds the login asynchronously.
        /// </summary>
        /// <param name="login">The login.</param>
        /// <returns></returns>
        public async Task <T> FindAsync(UserLoginInfo login)
        {
            var key     = KeyFormats.GetKey(login.LoginProvider, login.ProviderKey);
            var adapter = await _bucket.GetAsync <UserLoginInfoAdapter>(key);

            return(await _bucket.GetAsync <T>(adapter.UserId));
        }
Beispiel #2
0
        /// <summary>
        /// Removes a given login asynchronously
        /// </summary>
        /// <param name="user">The user.</param>
        /// <param name="login">The login.</param>
        /// <returns></returns>
        /// <exception cref="CouchbaseException">All server responses other than Success.</exception>
        /// <exception cref="Exception">Any client error condition.</exception>
        public async Task RemoveLoginAsync(T user, UserLoginInfo login)
        {
            var key = KeyFormats.GetKey(login.ProviderKey, user.Id);
            await _bucket.DeleteAsync(key);

            user.UserLoginIds.Remove(key);
            await _bucket.UpdateAsync(user.Id, user);
        }
Beispiel #3
0
        /// <summary>
        /// Adds the login to a user asynchronously.
        /// </summary>
        /// <param name="user">The user.</param>
        /// <param name="login">The login.</param>
        /// <returns></returns>
        /// <exception cref="CouchbaseException">All server responses other than Success.</exception>
        /// <exception cref="Exception">Any client error condition.</exception>
        public async Task AddLoginAsync(T user, UserLoginInfo login)
        {
            var adapter = new UserLoginInfoAdapter
            {
                LoginInfo = login,
                UserId    = user.Id
            };

            var key = KeyFormats.GetKey(login.LoginProvider, login.ProviderKey);
            await _bucket.CreateAsync(key, adapter);

            user.UserLoginIds.Add(key);
            await _bucket.UpdateAsync(user.Id, user);
        }