In the first case as long as the aircraft is operated by an AOC holder, no problem. It's effectively a wet or dry lease arrangement for the pilot and he is entitled to be paid.
In the second case it's flight sharing and the pilot would have to pay his share of the direct cost of the flight.