Can anyone help me how to change the object manager to a constructor in magento2:
$om = \Magento\Framework\App\ObjectManager::getInstance();
$customerSession = $om->get('Magento\Customer\Model\Session');
$customerData = $customerSession->getCustomer()->getData();
$customerId = $customerSession->getCustomerId();
$customerObj = $om->create('Magento\Customer\Model\Customer')
->load($customerId);
$customerData = $customerObj->getDataModel();
try {
$customerData->setCustomAttribute('r_what_percent_of_the_pharmacy', $r_what_percent_of_the_pharmacy);
$customerData->setCustomAttribute('r_what_percent_of_prescrip', $r_what_percent_of_prescrip);
$customerData->setCustomAttribute('r_how_many_total_prescriptions', $r_how_many_total_prescriptions);
$customerData->setCustomAttribute('r_has_the_owner_or_pharmacy', $r_has_the_owner_or_pharmacy);
$customerData->setCustomAttribute('r_does_the_pharmacy_solicit', $r_does_the_pharmacy_solicit);
$customerData->setCustomAttribute('r_is_your_clinic_or_pharmacy', $r_is_your_clinic_or_pharmacy);
$customerData->setCustomAttribute('r_are_one_or_more_practiti', $r_are_one_or_more_practiti);
$customerData->setCustomAttribute('r_does_the_pharmacy_offer', $r_does_the_pharmacy_offer);
$customerData->setCustomAttribute('r_any_exceptions', $r_any_exceptions);
$customerData->setCustomAttribute('r_any_exceptions_circumstances', $r_any_exceptions_circumstances);
$customerData->setCustomAttribute('r_does_the_pharmacy_clinic', $r_does_the_pharmacy_clinic);
$customerData->setCustomAttribute('r_currentstep', $r_currentstep);
$customerObj->updateData($customerData);
$customerObj->save();
} catch (Exception $e) {
return $e->getMessage();
}