示例#1
0
        public async Task Create(EnrollStudent model, SqlTransaction sqlTransaction, int idEnrollment)
        {
            await using var command = new SqlCommand(InsertStudentQuery, sqlTransaction.Connection)
                        {
                            CommandType = CommandType.Text,
                            Transaction = sqlTransaction
                        };

            var salt = PasswordHashHelper.CreateSalt();

            command.Parameters.AddWithValue("@IndexNumber", model.IndexNumber);
            command.Parameters.AddWithValue("@FirstName", model.FirstName);
            command.Parameters.AddWithValue("@Password", PasswordHashHelper.Create(model.Password, salt));
            command.Parameters.AddWithValue("@LastName", model.LastName);
            command.Parameters.AddWithValue("@BirthDate", model.BirthDate);
            command.Parameters.AddWithValue("@Salt", salt);
            command.Parameters.AddWithValue("@IdEnrollment", idEnrollment);

            await command.ExecuteNonQueryAsync();
        }