Donald Trump said he would accept the midterm results and work with Democrats. Their gains put control of Congress and his legislative agenda at stake.