The azimuthal anisotropy coefficient v_{2} of prompt D^{0}, D^{+}, D^{*+}, and D_{s}^{+} mesons was measured in midcentral (30%-50% centrality class) Pb-Pb collisions at a center-of-mass energy per nucleon pair sqrt[s_{NN}]=5.02 TeV, with the ALICE detector at the LHC. The D mesons were reconstructed via their hadronic decays at midrapidity, |y|<0.8, in the transverse momentum interval 1