// 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;
using System.Threading;
using System.Threading.Tasks;
namespace Microsoft.AspNetCore.Identity
{
///
/// Provides an abstraction for a store which manages user accounts.
///
/// The type encapsulating a user.
public interface IUserStore : IDisposable where TUser : class
{
///
/// Gets the user identifier for the specified .
///
/// The user whose identifier should be retrieved.
/// The used to propagate notifications that the operation should be canceled.
/// The that represents the asynchronous operation, containing the identifier for the specified .
Task GetUserIdAsync(TUser user, CancellationToken cancellationToken);
///
/// Gets the user name for the specified .
///
/// The user whose name should be retrieved.
/// The used to propagate notifications that the operation should be canceled.
/// The that represents the asynchronous operation, containing the name for the specified .
Task GetUserNameAsync(TUser user, CancellationToken cancellationToken);
///
/// Sets the given for the specified .
///
/// The user whose name should be set.
/// The user name to set.
/// The used to propagate notifications that the operation should be canceled.
/// The that represents the asynchronous operation.
Task SetUserNameAsync(TUser user, string userName, CancellationToken cancellationToken);
///
/// Gets the normalized user name for the specified .
///
/// The user whose normalized name should be retrieved.
/// The used to propagate notifications that the operation should be canceled.
/// The that represents the asynchronous operation, containing the normalized user name for the specified .
Task GetNormalizedUserNameAsync(TUser user, CancellationToken cancellationToken);
///
/// Sets the given normalized name for the specified .
///
/// The user whose name should be set.
/// The normalized name to set.
/// The used to propagate notifications that the operation should be canceled.
/// The that represents the asynchronous operation.
Task SetNormalizedUserNameAsync(TUser user, string normalizedName, CancellationToken cancellationToken);
///
/// Creates the specified in the user store.
///
/// The user to create.
/// The used to propagate notifications that the operation should be canceled.
/// The that represents the asynchronous operation, containing the of the creation operation.
Task CreateAsync(TUser user, CancellationToken cancellationToken);
///
/// Updates the specified in the user store.
///
/// The user to update.
/// The used to propagate notifications that the operation should be canceled.
/// The that represents the asynchronous operation, containing the of the update operation.
Task UpdateAsync(TUser user, CancellationToken cancellationToken);
///
/// Deletes the specified from the user store.
///
/// The user to delete.
/// The used to propagate notifications that the operation should be canceled.
/// The that represents the asynchronous operation, containing the of the update operation.
Task DeleteAsync(TUser user, CancellationToken cancellationToken);
///
/// Finds and returns a user, if any, who has the specified .
///
/// The user ID to search for.
/// The used to propagate notifications that the operation should be canceled.
///
/// The that represents the asynchronous operation, containing the user matching the specified if it exists.
///
Task FindByIdAsync(string userId, CancellationToken cancellationToken);
///
/// Finds and returns a user, if any, who has the specified normalized user name.
///
/// The normalized user name to search for.
/// The used to propagate notifications that the operation should be canceled.
///
/// The that represents the asynchronous operation, containing the user matching the specified if it exists.
///
Task FindByNameAsync(string normalizedUserName, CancellationToken cancellationToken);
}
}