Lagrangian structures and multidimensional consistency