First-principles calculations of magnetic interactions in correlated systems