/// <summary> /// Adds an external <see cref="T:Microsoft.AspNetCore.Identity.UserLoginInfo" /> to the specified <paramref name="user" />. /// </summary> /// <param name="user">The user to add the login to.</param> /// <param name="login">The external <see cref="T:Microsoft.AspNetCore.Identity.UserLoginInfo" /> to add to the specified <paramref name="user" />.</param> /// <param name="cancellationToken">The <see cref="T:System.Threading.CancellationToken" /> used to propagate notifications that the operation should be canceled.</param> /// <returns> /// The <see cref="T:System.Threading.Tasks.Task" /> that represents the asynchronous operation. /// </returns> public async Task AddLoginAsync(User user, UserLoginInfo login, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); user.ThrowIfArgumentIsNull(nameof(user)); login.ThrowIfArgumentIsNull(nameof(login)); var mapper = _mapperProvider.GetMapper <UserLoginInfo, UserLogin>(); var userLogin = mapper.Map(login); userLogin.UserId = user.Id; _unitOfWork.GetRepository <UserLogin>().Add(userLogin); await _unitOfWork.SaveChanges(cancellationToken); }