Skip to content
This repository was archived by the owner on Oct 27, 2022. It is now read-only.

Latest commit

 

History

History
54 lines (44 loc) · 1.62 KB

File metadata and controls

54 lines (44 loc) · 1.62 KB

ProfileStore.Client for Episerver

Simple .NET client library for accessing the Episerver Profile Store

Configuration

By default the library uses the following config settings to connect to the Profile Store, request these from Episerver support

<configuration>
  <appSettings>
    <add key="profileStore.RootApiUrl" value="" />
    <add key="profileStore.SubscriptionKey" value="" />
  </appSettings>
</configuration>

Example usage

using Newtonsoft.Json.Linq;
using ProfileStore.Client.Interfaces;

namespace YourProject
{
    public class ProfileClientDemo
    {
        private readonly IProfileStoreRepository _profileStoreRepository;

        public ProfileClientDemo(IProfileStoreRepository profileStoreRepository)
        {
            _profileStoreRepository = profileStoreRepository;
        }

        public JToken GetProfile(string deviceId)
        {
            // Note one profile can have more than one deviceId, 
            // where default tracking is used the deviceId is 
            // in the __madid cookie
            return _profileStoreRepository.GetProfileByDeviceId(deviceId);
        }

        public bool UpdateProfile(string deviceId)
        {
            var profile = _profileStoreRepository.GetProfileByDeviceId(deviceId);

            // Set the company name
            profile["Info"]["Company"] = "Episerver";
            
            // Set the person name
            profile["Name"] = "David Knipe";

            return _profileStoreRepository.UpdateProfile(profile).IsSuccessful;
        }
    }
}