Example #1
0
        public void CanGetCampaignSession()
        {
            if (!Debugger.IsAttached)
            {
                return;
            }

            //This will not work without refactoring away from sessions
            var response = WebApiService.GetCampaignSession(CampaignSessionModel.Current);

            Assert.IsNotNull(response);
        }
Example #2
0
        public ActionResult SignIn(string id, FormCollection collection)
        {
            bool authenticated   = false;
            var  campaignSession = CampaignSessionModel.Current;

            if (!string.IsNullOrEmpty(campaignSession.ExperienceUserId))
            {
                var signIn = new SignInModel {
                    Id = id
                };

                if (TryUpdateModel(signIn))
                {
                    campaignSession.LastName    = signIn.LastName;
                    campaignSession.DateOfBirth = signIn.BirthDate;
                    campaignSession.LastFour    = signIn.Ssn;

                    AuthorizationResponse authResponse =
                        WebApiService.GetAuthorization(lastName: campaignSession.LastName,
                                                       dateOfBirth: campaignSession.DateOfBirth, lastFour: campaignSession.LastFour);

                    if (!string.IsNullOrEmpty(authResponse.AuthHash))
                    {
                        campaignSession.AuthorizationHash = authResponse.AuthHash;
                        authenticated = true;
                    }
                    CampaignSessionModel.Current = campaignSession;
                }
            }
            if (authenticated)
            {
                HelperService.LogUserEvent(ExperienceEvents.AuthenticationSuccess, campaignSession.LastName);

                campaignSession = WebApiService.GetCampaignSession(CampaignSessionModel.Current);

                CampaignSessionModel.Current = campaignSession;

                return(RedirectToAction("Dynamic"));
            }
            HelperService.LogAnonEvent(ExperienceEvents.AuthenticationFail, campaignSession.LastName);

            return(RedirectToAction("Oops"));
        }
Example #3
0
        public ActionResult Index()
        {
            CampaignSessionModel campaignSession = CampaignSessionModel.Current;

            if (string.IsNullOrEmpty(campaignSession.ExperienceUserId))
            {
                ExperienceLogResponse logResponse = HelperService.LogInitialEvent(campaignSession.EmployerId);
                if (logResponse != null)
                {
                    campaignSession.ExperienceUserId = logResponse.ExperienceUserId;
                    CampaignSessionModel.Current     = campaignSession;
                }
            }

            if (null != Request.QueryString["cid"])
            {
                string   qparam  = Request.QueryString["cid"];
                string[] qparams = qparam.Split('|');

                if (qparams.Length >= 3 && qparams.Length <= 4)
                {
                    int employerId = int.Parse(qparams[0]);
                    int campaignId = int.Parse(qparams[1]);
                    int contentId  = int.Parse(qparams[2]);

                    if (campaignSession.EmployerId != employerId)
                    {
                        ExperienceLogResponse logResponse = HelperService.LogInitialEvent(employerId);
                        campaignSession.ExperienceUserId = logResponse.ExperienceUserId;
                        CampaignSessionModel.Current     = campaignSession;
                    }

                    campaignSession.EmployerId = employerId;
                    campaignSession.CampaignId = campaignId;
                    campaignSession.ContentId  = contentId;

                    var campaignIntro = WebApiService.GetCampaignIntro(
                        campaignSession.EmployerId,
                        campaignSession.CampaignId);

                    campaignSession.IntroAnimationType = campaignIntro.ContentType;
                    campaignSession.IntroAnimationName = campaignIntro.ContentName;
                    campaignSession.IntroContentId     = campaignIntro.ContentId;

                    CampaignSessionModel.Current = campaignSession;

                    if (qparams.Length == 4)
                    {
                        int cchId = int.Parse(qparams[3]);
                        campaignSession.CchId = cchId;

                        AuthorizationResponse authResponse = WebApiService.GetAuthorizationByCchId(
                            campaignSession.EmployerId,
                            campaignSession.CchId);

                        if (!string.IsNullOrEmpty(authResponse.AuthHash))
                        {
                            campaignSession.AuthorizationHash = authResponse.AuthHash;

                            CampaignSessionModel.Current = campaignSession;

                            campaignSession = WebApiService.GetCampaignSession(CampaignSessionModel.Current);

                            if (!string.IsNullOrEmpty(campaignSession.JavaScriptFileName))
                            {
                                campaignSession.IntroAnimationName = "NONE";
                            }
                            CampaignSessionModel.Current = campaignSession;

                            HelperService.LogUserEvent(ExperienceEvents.AuthenticationSuccess, campaignSession.CchId.ToString());
                        }
                        else
                        {
                            HelperService.LogAnonEvent(ExperienceEvents.AuthenticationFail, campaignSession.CchId.ToString());
                        }
                    }
                }
                else
                {
                    HelperService.LogAnonEvent(ExperienceEvents.InvalidQueryParameters, qparam);
                }
            }
            else
            {
                HelperService.LogAnonEvent(ExperienceEvents.NoQueryParameters);
            }
            ViewBag.Vid = campaignSession.PublicIntroVideoUrl;

            if (campaignSession.IntroAnimationName.Equals("NONE"))
            {
                return(RedirectToAction("Dynamic"));
            }

            if (!string.IsNullOrEmpty(campaignSession.IntroAnimationName))
            {
                HelperService.LogAnonEvent(ExperienceEvents.StartIntro,
                                           campaignSession.IntroAnimationName);
            }
            return(View());
        }