Charm-hadron production in pp and AA collisions