Optimal Incentive Contracting with Ex Ante and Ex Post Moral Hazards: Theory and Evidence