I am upgrading code from Sitecore 8.2 to Sitecore 9.3.
In Sitecore 8.2 we have a code snippet:-
public Contact GetCurrentContact()
{
if (Tracker.IsActive && Tracker.Current != null && Tracker.Current.Session != null)
{
return Tracker.Current.Session.Contact;
}
return null;
}
public Contact IdentifyContact(global::Sitecore.Security.Accounts.User user)
{
if (user == null)
return null;
string contactIdentifier = GetContactIdentifier(user);
if (string.IsNullOrEmpty(contactIdentifier) || contactIdentifier.Contains("anonymous") || Tracker.Current == null || Tracker.Current.Session == null)
{
return null;
}
Tracker.Current.Contact.Identifiers.AuthenticationLevel = AuthenticationLevel.PasswordValidated;
Tracker.Current.Session.Identify(contactIdentifier);
return Tracker.Current.Contact;
}
In this Sitecore 8.2 Contact object is coming from Sitecore.Analystics.Tracking but in Sitecore 9.3 do you need to convert Contact to Sitecore.XConnect.Contact?
I have another class to send and receive this Contact to/from Xdb in Sitecore 8.2
public void SaveContact(Contact contact)
{
// Save the contact and release the lock.
if (contact == null)
return;
var options = new ContactSaveOptions(release: true, owner: _leaseOwner);
_contactRepository.SaveContact(contact, options);
}
This is Sample code of that class. In this class also I am getting parameter contact in form on SItecore.Tracking.Analytics.Contact. How can I convert this contact to XConnect.Contact for Sitecore 9.3?