Controllable magnetoresistance device based on a d-doped magnetic nanostructure