// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
namespace Microsoft.AspNetCore.Identity
{
///
/// Provides an abstraction for a store which maps users to roles.
///
/// The type encapsulating a user.
public interface IUserRoleStore : IUserStore where TUser : class
{
///
/// Add the specified to the named role.
///
/// The user to add to the named role.
/// The name of the role to add the user to.
/// The used to propagate notifications that the operation should be canceled.
/// The that represents the asynchronous operation.
Task AddToRoleAsync(TUser user, string roleName, CancellationToken cancellationToken);
///
/// Remove the specified from the named role.
///
/// The user to remove the named role from.
/// The name of the role to remove.
/// The used to propagate notifications that the operation should be canceled.
/// The that represents the asynchronous operation.
Task RemoveFromRoleAsync(TUser user, string roleName, CancellationToken cancellationToken);
///
/// Gets a list of role names the specified belongs to.
///
/// The user whose role names to retrieve.
/// The used to propagate notifications that the operation should be canceled.
/// The that represents the asynchronous operation, containing a list of role names.
Task> GetRolesAsync(TUser user, CancellationToken cancellationToken);
///
/// Returns a flag indicating whether the specified is a member of the given named role.
///
/// The user whose role membership should be checked.
/// The name of the role to be checked.
/// The used to propagate notifications that the operation should be canceled.
///
/// The that represents the asynchronous operation, containing a flag indicating whether the specified is
/// a member of the named role.
///
Task IsInRoleAsync(TUser user, string roleName, CancellationToken cancellationToken);
///
/// Returns a list of Users who are members of the named role.
///
/// The name of the role whose membership should be returned.
/// The used to propagate notifications that the operation should be canceled.
///
/// The that represents the asynchronous operation, containing a list of users who are in the named role.
///
Task> GetUsersInRoleAsync(string roleName, CancellationToken cancellationToken);
}
}