/// <summary> /// Finds and returns a user, if any, who has the specified <paramref name="userId"/>. /// </summary> /// <param name="userId">The user ID to search for.</param> /// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param> /// <returns> /// The <see cref="Task"/> that represents the asynchronous operation, containing the user matching the specified <paramref name="userId"/> if it exists. /// </returns> public override Task <User> FindByIdAsync(string userId, CancellationToken cancellationToken = default(CancellationToken)) { cancellationToken.ThrowIfCancellationRequested(); ThrowIfDisposed(); var id = ConvertIdFromString(userId); return(UsersSet.FindAsync(new object[] { id }, cancellationToken)); }
public virtual async Task <TUser> FindByEmailAsync(string email) { var emails = Emails.Where(e => e.Email.Equals(email)); if (emails.Any()) { return(await UsersSet.FindAsync(emails.First().UserId)); } return(null); }