Many-particle theory of the electronic and optical properties of semiconductors, metals, and their nanostructures; spin-dependent dynamics in metals, ferromagnets and materials with high spin polarization