Theory of magnetotransport in inhomogeneous magnetic structures