Two goals from Niall McGinn were enough to give Aberdeen a well-deserved 2-0 win over struggling Hearts at Pittodrie.