public async Task <IdentityResult> CreateAsync(ApplicationUserIdentity user, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); var dataTable = new DataTable(); dataTable.Columns.Add("Username", typeof(string)); dataTable.Columns.Add("NormalizedUsername", typeof(string)); dataTable.Columns.Add("Email", typeof(string)); dataTable.Columns.Add("NormalizedEmail", typeof(string)); dataTable.Columns.Add("Fullname", typeof(string)); dataTable.Columns.Add("PasswordHash", typeof(string)); dataTable.Rows.Add( user.Username, user.NormlizedUsername, user.Email, user.NormlizedUsername, user.Fullname, user.PasswordHash ); using (var connection = new SqlConnection(_config.GetConnectionString("DefaultConnection"))) { await connection.OpenAsync(cancellationToken); await connection.ExecuteAsync("Account_Insert", new { Account = dataTable.AsTableValuedParameter("dbo.AccountType") }, commandType : CommandType.StoredProcedure); } return(IdentityResult.Success); }
public async System.Threading.Tasks.Task <Task <ApplicationUserIdentity> > GetByUsernameAsync(string normalizedUsername, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); ApplicationUserIdentity applicationUser; using (var connection = new SqlConnection(_config.GetConnectionString("DefaultConnection"))) { await connection.OpenAsync(cancellationToken); ApplicationUserIdentity applicationUserIdentity = connection.QuerySingleOrDefault <ApplicationUserIdentity>( "Account_GetByUsername", new { NormalizedUsername = normalizedUsername }, commandType: CommandType.StoredProcedure); applicationUser = await applicationUserIdentity; } return(applicationUser); }