protected void UpdateAgeGroupProfile(DemographicsPayload data)
        {
            Tracker.Current.Interaction.Profiles.Remove("Age Group");
            var ageGroupScoring = new Dictionary <string, double>
            {
                { data.AgeGroup, 10 }
            };

            Tracker.Current.Interaction.Profiles["Age Group"].Score(ageGroupScoring);
        }
        protected void UpdateGenderProfile(DemographicsPayload data)
        {
            Tracker.Current.Interaction.Profiles.Remove("Gender");
            var genderScoring = new Dictionary <string, double>
            {
                { data.Gender, 10 }
            };

            Tracker.Current.Interaction.Profiles["Gender"].Score(genderScoring);
        }
        public void UpdateFacet([NotNull] DemographicsPayload data)
        {
            var trackerContact = ContactExtensions.GetCurrentTrackerContact();

            Assert.IsNotNull(trackerContact, "Current contact is null");

            var facets = trackerContact.GetXConnectFacets();

            UpdateAgeGroup(data, facets);
            UpdateGender(data, facets);

            trackerContact.UpdateXConnectFacets(facets);
        }
        public ActionResult UpdateProfile([System.Web.Http.FromBody] DemographicsPayload data)
        {
            try
            {
                service.UpdateProfile(data);
            }
            catch (Exception ex)
            {
                Log.Error($"Error while running UpdateProfile API", ex, this);
                return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError, ex.Message));
            }

            return(new HttpStatusCodeResult(HttpStatusCode.OK));
        }
        protected void UpdateGender(DemographicsPayload data, Dictionary <string, Facet> facets)
        {
            PersonalInformation personalInfo;

            if (facets.ContainsKey(PersonalInformation.DefaultFacetKey))
            {
                personalInfo        = (PersonalInformation)facets[PersonalInformation.DefaultFacetKey];
                personalInfo.Gender = data.Gender;
            }
            else
            {
                personalInfo = new PersonalInformation()
                {
                    Gender = data.Gender,
                };

                facets.Add(PersonalInformation.DefaultFacetKey, personalInfo);
            }
        }
        protected void UpdateAgeGroup(DemographicsPayload data, Dictionary <string, Facet> facets)
        {
            DemographicsFacet facet;

            if (facets.ContainsKey(DemographicsFacet.DefaultKey))
            {
                facet          = (DemographicsFacet)facets[DemographicsFacet.DefaultKey];
                facet.AgeGroup = data.AgeGroup;
            }
            else
            {
                facet = new DemographicsFacet()
                {
                    AgeGroup = data.AgeGroup,
                };

                facets.Add(DemographicsFacet.DefaultKey, facet);
            }
        }
 public void UpdateProfile([NotNull] DemographicsPayload data)
 {
     UpdateGenderProfile(data);
     UpdateAgeGroupProfile(data);
 }