Exemple #1
0
        public IHttpActionResult Index([FromBody] IdentifyViewModel vm)
        {
            ITrackerService service = new TrackerService();

            service.IdentifyContact(vm.PersonId);

            var response = new ProfileViewModel(contactProfileProvider);

            var name = contactProfileProvider.PersonalInfo.FirstName;

            Guid guid;

            // if name is empty, unkown or it has a guid, treat it as "no name". The client should trigger the update name action
            if (string.IsNullOrEmpty(name) ||
                string.Compare(name, "unknown", true, CultureInfo.CurrentCulture) == 0 ||
                Guid.TryParse(name, out guid))
            {
                response.Name = string.Empty;
            }
            else
            {
                response.Name = name;
            }

            return(new JsonResult <ProfileViewModel>(response, new JsonSerializerSettings(), Encoding.UTF8, this));
        }
 public void IdentifyContact_ValidIdentifier_ShouldIdentifyContact([NoAutoProperties] TrackerService trackerService, string contactIdentifier, ITracker tracker, [Substitute] Session session)
 {
     tracker.IsActive.Returns(true);
     tracker.Session.Returns(session);
     using (new TrackerSwitcher(tracker))
     {
         trackerService.IdentifyContact(contactIdentifier);
         tracker.Session.Received().Identify(contactIdentifier);
     }
 }