NEW YORK—Mayor Bill de Blasio has had to work overtime in the past few weeks. In between his regular duties and working to contain both the Ebola outbreak and the city’s panic over the virus, the mayor has pushed and pulled behind the scenes to secure control of the state senate by Democrats.