public ActionResult WhatWeKnowAboutYou()
        {
            Contact trackingContact = Tracker.Current.Contact;

            var knownDataHelper = new KnownDataHelper();

            KnownData knownDataXConnect = null;

            //Task.Run(async () =>
            //{
            //  knownDataXConnect = await knownDataHelper.GetKnownDataByIdentifierViaXConnect(QueryStringHelper.UserId);
            //}
            //).Wait();

            //KnownData knownDataViaTracker = null;// knownDataHelper.GetKnownDataViaTracker(trackingContact);
            KnownData knownDataViaTracker = knownDataHelper.GetKnownDataViaTracker(trackingContact);

            //Tracker.Current.Contact // <--- Use this
            // use other Contact outside of a web page.

            //knownDataTracker.IsNew = trackingContact.IsNew;

            if (knownDataXConnect != null)
            {
                knownDataHelper.AppendCurrentContextData(knownDataXConnect, Sitecore.Context.Database);
            }

            var viewModel = new WhatWeKnowAboutYouViewModel
            {
                KnownDataXConnect = knownDataViaTracker,
                KnownDataTracker  = null
            };

            return(View(viewModel));
        }
Beispiel #2
0
        public async Task WatchAMovieAsync()
        {
            var watchMovieInteration = new WatchMovieInteraction(Identifier);

            var arr = new[]
            {
                @" __  __            _      ",
                @"|  \/  | _____   _(_) ___ ",
                @"| |\/| |/ _ \ \ / / |/ _ \",
                @"| |  | | (_) \ V /| |  __/",
                @"|_|  |_|\___/ \_/ |_|\___|",
            };

            DrawStepTitle(arr);
            await watchMovieInteration.ExecuteInteraction();


            var reporter                = new DataReporter();
            var knownDataHelper         = new KnownDataHelper();
            KnownDataXConnect knownData = await knownDataHelper.GetKnownDataByIdentifierViaXConnect(Identifier);


            if (knownData?.PersonalInformationDetails != null)
            {
                System.Console.WriteLine("Enjoy your movie, " + knownData.PersonalInformationDetails.FirstName + "!");
                System.Console.WriteLine("Since you're a loyalty card holder, we'll take payment for your ticket now.");
            }
            else
            {
                System.Console.WriteLine("Details was null");
            }

            // Initialize a client using the validate configuration

            if (watchMovieInteration.XConnectContact != null)
            {
                DrawTriggerMessage("You scanned your ticket - the bar code has your loyalty card information embedded in it.");
            }

            System.Console.ReadKey();
        }
Beispiel #3
0
        public async Task BuyCandy()
        {
            //   ___       _                      _   _               _  _  ____
            //  |_ _|_ __ | |_ ___ _ __ __ _  ___| |_(_) ___  _ __  _| || ||___ \
            //   | || '_ \| __/ _ \ '__/ _  |/ __| __| |/ _ \| '_ \|_  ..  _|__) |
            //   | || | | | ||  __/ | | (_| | (__| |_| | (_) | | | |_      _/ __/
            //  |___|_| |_|\__\___|_|  \__,_|\___|\__|_|\___/|_| |_| |_||_||_____|

            // You decides to buy some candy and a bottle of water (gotta stay balanced)
            // You use your loyalty card - that's 2 swipes already! The machine sends this interaction to xConnect.

            var arr = new[]  {
                @"  ____                _       ",
                @" / ___|__ _ _ __   __| |_   _ ",
                @"| |   / _` | '_ \ / _` | | | |",
                @"| |__| (_| | | | | (_| | |_| |",
                @" \____\__,_|_| |_|\__,_|\__, |",
                @"                        |___/ ",
            };

            DrawStepTitle(arr);

            var buyCandyInteraction = new BuyCandyInteraction(Identifier);

            await buyCandyInteraction.ExecuteInteraction();

            DrawTriggerMessage("You swiped your loyalty card.");

            if (buyCandyInteraction.XConnectContact != null)
            {
                var knownDataHelper         = new KnownDataHelper();
                KnownDataXConnect knownData = await knownDataHelper.GetKnownDataByIdentifierViaXConnect(Identifier);


                System.Console.WriteLine("Why hello again " + knownData.PersonalInformationDetails.FirstName + "!");
                System.Console.WriteLine("Candy? You got it.");

                DrawPostInteractionMessage("Enjoy the movie!");
            }
        }
        public async Task ExecuteStep()
        {
            var arr = new[]
            {
                @" _____ _      _        _   ",
                @"|_   _(_) ___| | _____| |_ ",
                @"  | | | |/ __| |/ / _ \ __|",
                @"  | | | | (__|   <  __/ |_ ",
                @"  |_| |_|\___|_|\_\___|\__|",
            };

            DrawStepTitle(arr);
            DrawTriggerMessage("You swiped your loyalty card.");

            var selfServiceMachineInteraction = new SelfServiceMachineInteraction(Identifier);

            await selfServiceMachineInteraction.ExecuteInteraction();

            var knownDataHelper         = new KnownDataHelper();
            KnownDataXConnect knownData = await knownDataHelper.GetKnownDataByIdentifierViaXConnect(Identifier);

            if (!selfServiceMachineInteraction.Errors.Any() && knownData?.PersonalInformationDetails != null &&
                knownData.VisitorInfoMovie != null)
            {
                Feedback.WriteLine("Why hello there " +
                                   knownData.PersonalInformationDetails.FirstName + " "
                                   + knownData.PersonalInformationDetails.LastName
                                   + ", whose favorite film is..." + knownData.VisitorInfoMovie.FavoriteMovie
                                   + ". Wow, really? Ok, to each their own I guess.");

                DrawPostInteractionMessage(new string[] {
                    "Here's your ticket - we'll charge you when you use it, in case you have some sort of emergency between here and the movie",
                    "It's just one of those courtesies we offer loyalty card member! Now go buy some candy."
                }
                                           );
            }
        }
Beispiel #5
0
        public async Task ReportAsync()
        {
            try
            {
                Feedback.WriteLine("Before you go - do you want to see the data we collected about you today? :)");

                var knownDataHelper = new KnownDataHelper();

                KnownDataXConnect knownData = await knownDataHelper.GetKnownDataByIdentifierViaXConnect(Identifier);

                if (knownDataHelper != null)
                {
                    if (knownData.ContactId != null)
                    {
                        Feedback.WriteLine(string.Format("Contact id: " + knownData.ContactId));
                    }

                    if (knownData?.PersonalInformationDetails != null && knownData.VisitorInfoMovie != null)
                    {
                        Feedback.WriteLine(string.Format("Your name is {0} {1} and your favorite movie is {2}",
                                                         knownData.PersonalInformationDetails.FirstName,
                                                         knownData.PersonalInformationDetails.LastName,
                                                         knownData.VisitorInfoMovie.FavoriteMovie));
                    }
                    else
                    {
                        Feedback.WriteLine("details or movie was null");
                    }

                    if (knownData?.KnownInteractions != null)
                    {
                        Feedback.WriteLine("Today you have had " + knownData.KnownInteractions.Count + " interactions with us");

                        var i = 0;

                        foreach (var interactionsToday in knownData.KnownInteractions)
                        {
                            i++;
                            var cinemaId = interactionsToday.RawInteraction.GetFacet <CinemaInfo>(CinemaInfo.DefaultFacetKey);
                            Feedback.WriteLine("");

                            Feedback.WriteLine("Interaction #" + i + (cinemaId != null ? " at Cinema #" + cinemaId.CinimaId : string.Empty));

                            Feedback.WriteLine("Events: ");

                            foreach (var evv in interactionsToday.Events)
                            {
                                Feedback.WriteLine(evv.GetType().ToString() + "");
                            }
                            ;
                            Feedback.WriteLine("");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Feedback.WriteLine(ex.Message);
                throw;
            }
            Feedback.ReadKey();
        }