Exemplo n.º 1
0
        public ActionResult DelayedRecords()
        {
            //return null;
            string url = "http://www.explore-schools.com/thankyou/affiliate_submission.php";

            DelayedRecordClient drc = new DelayedRecordClient();
            //drc.DeleteTable();
            List <DelayedRecord> allrecords = new List <DelayedRecord>(drc.GetAll().Execute());

            DateTime cursordate = DateTime.UtcNow.AddMinutes(-30);

            UserProfileClient upc = new UserProfileClient();

            int cnt = 0;

            foreach (DelayedRecord dr in allrecords)
            {
                cnt++;
                if (dr.Timestamp < cursordate)
                {
                    dr.Submitted = true;
                    try
                    {
                        string strPost = dr.GetPostString(upc);

                        StreamWriter   myWriter   = null;
                        HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(url);
                        objRequest.Method        = "POST";
                        objRequest.ContentLength = System.Text.ASCIIEncoding.ASCII.GetByteCount(strPost);
                        objRequest.ContentType   = "application/x-www-form-urlencoded";

                        myWriter = new StreamWriter(objRequest.GetRequestStream());
                        myWriter.Write(strPost);
                        myWriter.Close();

                        HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse();
                        using (StreamReader sr =
                                   new StreamReader(objResponse.GetResponseStream()))
                        {
                            string result = sr.ReadToEnd();
                            if (result.Contains("Success") || result.ToLower().Contains("already in our database"))
                            {
                                drc.Delete(dr);
                            }
                            else
                            {
                                dr.SubmissionError = true;
                            }

                            // Close and clean up the StreamReader
                            sr.Close();
                        }
                    }catch (Exception e)
                    {
                        drc.Delete(dr);
                    }



                    //if (++cnt >= 30)
                    //{
                    //    break;
                    //}
                }
            }

            ViewBag.SubmittedRecords = cnt;

            return(View(allrecords));
        }
        public ActionResult Index(FormCollection collection)
        {
            if (Request.Cookies["extendedrecordcomplete"] != null)
            {
                return(RedirectToAction("Index", "SkillTest"));
            }

            #region IP ADDRESS
#if DEBUG
            string randomip = RandomHelper.Instance.Next(1, 256) + "." + RandomHelper.Instance.Next(0, 256) + "." + RandomHelper.Instance.Next(0, 256) + "." + RandomHelper.Instance.Next(1, 256);
#endif
            string ipaddress = "";
#if DEBUG
            ipaddress = randomip;
#else
            ipaddress = Request.UserHostAddress;
#endif
            #endregion

            double LEAD_CONVERSION_VALUE   = 1;
            double RECORD_CONVERSION_VALUE = 0.2;

            double conversionValue = 0;

            string schoolsearchresultid = FromCookie("schoolsearchresultid");

            string campaignid = FormValue(collection, "cbncampaign", "13564694");

            string salutation = FormValue(collection, "salutation", "").Trim().ToProperCase();
            string gender     = salutation.ToLower() == "mr" ? "M" : "F";
            string firstname  = FormValue(collection, "firstname", "GET THIS");
            string lastname   = FormValue(collection, "lastname", "GET THIS");

            string email    = FormValue(collection, "email", "GET THIS").Trim().ToLower();
            string zip      = FormValue(collection, "zip", "GET THIS");
            string phone    = FormValue(collection, "phone", "GET THIS").Replace(".", "").Replace(" ", "").Replace("-", "").Replace("(", "").Replace(")", "");
            string address1 = FormValue(collection, "address1", "GET THIS");
            string city     = FormValue(collection, "city", "");
            string state    = FormValue(collection, "state", "");

            string educationlevel = FormValue(collection, "education_level", "SC");
            string eduintent      = FormValue(collection, "edu_intent", "YES");
            string military       = FormValue(collection, "military", "None");
            string gradyear       = FormValue(collection, "gradyear", "GET THIS");
            string sourceform     = FormValue(collection, "sourceform", "");

            string dobyear = FormValue(collection, "dobyear", "");

            Random rnd      = new Random(DateTime.Now.Millisecond);
            int    dobmonth = rnd.Next(1, 13);
            int    dobday   = rnd.Next(1, 29);

            string schoolvariables = "";
            if (Request.Cookies["schoolvariables"] != null)
            {
                schoolvariables = HttpUtility.UrlDecode(Request.Cookies["schoolvariables"].Value);
            }

            //GA variable
            string utmsource   = FromCookie("utm_source"),
                   utmcampaign = FromCookie("utm_campaign"),
                   utmcontent  = FromCookie("utm_content"),
                   utmterm     = FromCookie("utm_term");

            //Advertise.com variables
            string advertise_affsub        = FromCookie("AFFSUB"),
                   advertise_affiliate     = FromCookie("AFFILIATE"),
                   advertise_country       = FromCookie("COUNTRY"),
                   advertise_countrycode   = FromCookie("COUNTRYCODE"),
                   advertise_geo           = FromCookie("GEO"),
                   advertise_subid         = FromCookie("SUBID"),
                   advertise_terms_html_kw = FromCookie("TERMS_HTML_KW"),
                   advertise_terms         = FromCookie("TERMS");

            string[] distinctSubmissions = schoolvariables.Split('^');
            foreach (string submission in distinctSubmissions)
            {
                if (submission != "")
                {
                    string[] submissionTokens = submission.Split('!');

                    string campuskey  = submissionTokens[3];
                    string programkey = submissionTokens.Length > 4 ? submissionTokens[4] : "";



                    String strPost = "campaign_id=" + campaignid +
                                     "&id=1727" +
                                     "&ip=" + ipaddress +
                                     "&client_id=" + submissionTokens[1] +
                                     "&salutation=" + salutation +
                                     "&gender=" + gender +
                                     "&firstname=" + firstname.Trim() +
                                     "&lastname=" + lastname.Trim() +
                                     "&email=" + email +
                                     "&zip=" + zip +
                                     "&phone=" + phone +
                                     "&address1=" + address1 +
                                     "&city=" + city +
                                     "&state=" + state +
                                     "&education_level=" + educationlevel +
                                     "&educationlevel=" + educationlevel +
                                     "&edu_intent=YES" +
                                     "&military=" + military +
                                     "&campus_key=" + submissionTokens[3] +
                                     "&program_key=" + programkey +
                                     "&gradyear=" + gradyear +
                                     "&dobyear=" + dobyear +
                                     "&dobmonth=" + dobmonth.ToString() +
                                     "&dobday=" + dobday.ToString() +
                                     "&form_id=" + submissionTokens[2] +
                                     "&program=" + submissionTokens[0];

                    int igradyear;
                    int.TryParse(gradyear, out igradyear);

                    //Do not submit young leads to CBN
                    if (igradyear <= DateTime.Now.Year)
                    {
                        //Update the record with address
                        DelayedRecordClient drc = new DelayedRecordClient();
                        //First check if delayed record already exists for this email
                        DelayedRecord dr = drc.GetByRowKey(email.FormatEmailAsProgrammaticId());
                        if (dr != null)
                        {
                            if (dr.Address1 != address1)
                            {
                                dr.Address1  = address1;
                                dr.EduIntent = "YES";
                                drc.Update(dr);
                            }
                        }
                    }

                    string submissionResult = "";

                    try
                    {
                        if (igradyear <= DateTime.Now.Year)
                        {
                            submissionResult = SubmitLead(strPost);
                            conversionValue += LEAD_CONVERSION_VALUE;
                        }

                        SkillCowRequestSubmissionClient rsc = new SkillCowRequestSubmissionClient();

                        string mode = "external";
                        if (Request.Cookies["mode"] != null)
                        {
                            mode = Request.Cookies["mode"].Value;
                        }

                        string testresults = "";
                        if (Request.Cookies["testresults"] != null)
                        {
                            testresults = DecodeCookieCharacters(Request.Cookies["testresults"].Value);
                        }

                        string recommendations = "";
                        if (Request.Cookies["recommendations"] != null)
                        {
                            recommendations = DecodeCookieCharacters(Request.Cookies["recommendations"].Value);
                        }

                        string careerChoicesJson = GetCareerChoicesJson();
                        string data = "{\"careerchoices\":" + careerChoicesJson + "}";

                        rsc.AddNewItem(new SkillCowRequestSubmission
                        {
                            Salutation       = salutation,
                            Name             = (firstname + " " + lastname).Trim(),
                            Zip              = zip,
                            Email            = email,
                            Address1         = address1,
                            Phone            = phone,
                            IP               = ipaddress,
                            Mode             = mode,
                            CampaignId       = campaignid,
                            TestResults      = testresults,
                            SourceForm       = collection["sourceform"],
                            GradYear         = gradyear,
                            EduIntent        = eduintent,
                            Recommendations  = recommendations,
                            ClientId         = submissionTokens[1],
                            FormId           = submissionTokens[2],
                            Gender           = gender,
                            CareerId         = submissionTokens[0],
                            SubmissionResult = submissionResult,
                            Data             = data,
                            UtmSource        = utmsource,
                            UtmCampaign      = utmcampaign,
                            UtmContent       = utmcontent,
                            UtmTerm          = utmterm

                            ,
                            City = city
                            ,
                            State = state
                            ,
                            CampusKey = campuskey
                            ,
                            ProgramKey = programkey

                            ,
                            advertise_affsub = advertise_affsub
                            ,
                            advertise_affiliate = advertise_affiliate
                            ,
                            advertise_country = advertise_country
                            ,
                            advertise_countrycode = advertise_countrycode
                            ,
                            advertise_geo = advertise_geo
                            ,
                            advertise_subid = advertise_subid
                            ,
                            advertise_terms = advertise_terms
                            ,
                            advertise_terms_html_kw = advertise_terms_html_kw,

                            PostedString         = strPost,
                            SchoolSearchResultId = schoolsearchresultid
                        });


                        if (campaignid == "13564694")
                        {
                            //Telephony t = new Telephony();
                            //t.SendSMS("+19174340659", "Web lead: " + firstname + " " + lastname);
                        }
                    }
                    catch (Exception ex)
                    {
                    }
                }
            }

            AddresseeClient adc            = new AddresseeClient();
            string          emailpartition = AddresseeClient.GetPartitionKeyForEmail(email);
            Addressee       a = adc.GetByPartitionAndRowKey(emailpartition, email);
            if (a == null)
            {
                adc.AddNewItem(new Addressee(email.ToLower())
                {
                    Name = firstname, Email = email.ToLower(),
                });

                UserProfileClient upc     = new UserProfileClient();
                UserProfile       profile = new UserProfile(email.ToLower())
                {
                    Gender       = gender,
                    Salutation   = salutation,
                    FirstName    = firstname,
                    LastName     = lastname,
                    Email        = email,
                    Unsubscribed = false,
                    Zip          = zip,
                    Address1     = address1,
                    City         = city,
                    State        = state,
                    Phone        = phone,
                    CampaignId   = campaignid,
                    GradYear     = gradyear,
                    EduIntent    = eduintent
                };
                profile.PopulateCityAndState();
                profile.SetTestResults(Request);
                profile.SetImportantThings(Request);
                upc.AddNewItem(profile);
            }

            ABTestClient abtc = null;
            abtc = new ABTestClient("Home", Request, Response);
            abtc.CreateGoalConversion("schoolleads", distinctSubmissions.Length);

            Response.Cookies["extendedrecordcomplete"].Value   = "1";
            Response.Cookies["extendedrecordcomplete"].Expires = DateTime.UtcNow.AddDays(90);

            //Only set this cookie for internal
            if (campaignid != "13564694")
            {
                Response.Cookies["ascv"].Value   = conversionValue.ToString();
                Response.Cookies["ascv"].Expires = DateTime.UtcNow.AddDays(90);
            }

            return(RedirectToAction("Index", "SkillTest", new { f = "thanks" }));
        }
Exemplo n.º 3
0
        public ActionResult Index(FormCollection collection)
        {
            if (Request.Cookies["recordsubmitted"] != null)
            {
                return(View());
            }

#if DEBUG
            string randomip = RandomHelper.Instance.Next(1, 256) + "." + RandomHelper.Instance.Next(0, 256) + "." + RandomHelper.Instance.Next(0, 256) + "." + RandomHelper.Instance.Next(1, 256);
#endif

            string ipaddress = "";
#if DEBUG
            ipaddress = randomip;
#else
            ipaddress = Request.UserHostAddress;
#endif
            string salutation = FormValue(collection, "salutation", "").Trim().ToProperCase();
            string gender     = salutation.ToLower() == "mr" ? "M" : "F";

            string firstname = FormValue(collection, "firstname", "GET THIS");
            string lastname  = FormValue(collection, "lastname", "GET THIS");
            string email     = FormValue(collection, "email", "GET THIS");
            string zip       = FormValue(collection, "zip", "GET THIS");
            string phone     = FormValue(collection, "phone", "GET THIS").Replace(".", "").Replace(" ", "").Replace("-", "").Replace("(", "").Replace(")", "");
            string address   = FormValue(collection, "address1", "GET THIS");
            string city      = FormValue(collection, "city", "GET THIS");
            string state     = FormValue(collection, "state", "GET THIS");
            string edulevel  = FormValue(collection, "education_level", "GET THIS");
            string campaign  = FormValue(collection, "cbncampaign", "13564694"); //(collection["campaign_id"] == null || collection["campaign_id"] == "" ? "GET THIS" : collection["campaign_id"]);

            string gradyear  = FormValue(collection, "gradyear", "GET THIS");    //(collection["gradyear"] == null || collection["gradyear"] == "" ? "GET THIS" : collection["gradyear"]);
            string eduintent = FormValue(collection, "edu_intent", "GET THIS");  //(collection["edu_intent"] == null || collection["edu_intent"] == "" ? "GET THIS" : collection["edu_intent"]);
            string dobyear   = FormValue(collection, "dobyear", "");

            Random rnd      = new Random(DateTime.Now.Millisecond);
            string dobmonth = rnd.Next(1, 13).ToString();
            string dobday   = rnd.Next(1, 29).ToString();


            string utmsource = "", utmcampaign = "", utmcontent = "", utmterm = "";
            if (Request.Cookies["utm_source"] != null)
            {
                utmsource = HttpUtility.UrlDecode(Request.Cookies["utm_source"].Value);
            }
            if (Request.Cookies["utm_campaign"] != null)
            {
                utmcampaign = HttpUtility.UrlDecode(Request.Cookies["utm_campaign"].Value);
            }
            if (Request.Cookies["utm_content"] != null)
            {
                utmcontent = HttpUtility.UrlDecode(Request.Cookies["utm_content"].Value);
            }
            if (Request.Cookies["utm_term"] != null)
            {
                utmterm = HttpUtility.UrlDecode(Request.Cookies["utm_term"].Value);
            }

            int igradyear;
            int.TryParse(gradyear, out igradyear);

            String result  = "";
            String strPost = "campaign_id=" + campaign +
                             "&id=1727" +
                             "&ip=" + ipaddress +
                             "&client=20" +
                             "&salutation=" + salutation +
                             "&gender=" + gender +
                             "&firstname=" + firstname.Trim() +
                             "&lastname=" + lastname.Trim() +
                             "&email=" + email +
                             "&address1=" + address +
                             "&city=" + city +
                             "&state=" + state +
                             "&zip=" + zip +
                             "&phone=" + phone +
                             "&educationlevel=" + edulevel +
                             "&education_level=" + edulevel +
                             "&edu_intent=" + eduintent +
                             "&gradyear=" + gradyear +
                             "&dobyear=" + dobyear +
                             "&dobmonth=" + dobmonth +
                             "&dobday=" + dobday;

            if (igradyear <= DateTime.Now.Year)
            {
                //Create delayed record
                DelayedRecordClient drc = new DelayedRecordClient();
                //First check if delayed record already exists for this email
                DelayedRecord dr = drc.GetByRowKey(email.FormatEmailAsProgrammaticId());
                if (dr == null)
                {
                    drc.AddNewItem(new DelayedRecord
                    {
                        RowKey         = email.FormatEmailAsProgrammaticId(),
                        CampaignId     = campaign,
                        ClientId       = "20",
                        IP             = ipaddress,
                        Salutation     = salutation,
                        Gender         = gender,
                        FirstName      = firstname,
                        LastName       = lastname,
                        Email          = email,
                        Address1       = address,
                        City           = city,
                        State          = state,
                        Zip            = zip,
                        Phone          = phone,
                        EducationLevel = edulevel,
                        EduIntent      = eduintent,
                        GradYear       = gradyear,
                        DobYear        = dobyear,
                        DobMonth       = dobmonth,
                        DobDay         = dobday
                    });
                }
            }


            SkillCowRequestSubmissionClient rsc = new SkillCowRequestSubmissionClient();

            string mode = "external";
            if (Request.Cookies["mode"] != null)
            {
                mode = Request.Cookies["mode"].Value;
            }

            string testresults = "";
            if (Request.Cookies["testresults"] != null)
            {
                testresults = DecodeCookieCharacters(Request.Cookies["testresults"].Value);
            }

            string recommendations = "";
            if (Request.Cookies["recommendations"] != null)
            {
                recommendations = DecodeCookieCharacters(Request.Cookies["recommendations"].Value);
            }

            string careerChoicesJson = GetCareerChoicesJson();
            string data = "{\"careerchoices\":" + careerChoicesJson + "}";

            //Advertise.com variables
            string advertise_affsub        = FromCookie("AFFSUB"),
                   advertise_affiliate     = FromCookie("AFFILIATE"),
                   advertise_country       = FromCookie("COUNTRY"),
                   advertise_countrycode   = FromCookie("COUNTRYCODE"),
                   advertise_geo           = FromCookie("GEO"),
                   advertise_subid         = FromCookie("SUBID"),
                   advertise_terms_html_kw = FromCookie("TERMS_HTML_KW"),
                   advertise_terms         = FromCookie("TERMS");

            rsc.AddNewItem(new SkillCowRequestSubmission {
                Gender = gender, Salutation = salutation, State = state, City = city, Name = firstname, Zip = zip, Email = email, Phone = phone, IP = ipaddress, Mode = mode, CampaignId = campaign, TestResults = testresults, SourceForm = collection["sourceform"], GradYear = gradyear, EduIntent = eduintent, Data = data, Recommendations = recommendations, UtmSource = utmsource, UtmCampaign = utmcampaign, UtmContent = utmcontent, UtmTerm = utmterm

                , SubmissionResult = result

                , advertise_affsub        = advertise_affsub
                , advertise_affiliate     = advertise_affiliate
                , advertise_country       = advertise_country
                , advertise_countrycode   = advertise_countrycode
                , advertise_geo           = advertise_geo
                , advertise_subid         = advertise_subid
                , advertise_terms         = advertise_terms
                , advertise_terms_html_kw = advertise_terms_html_kw
            });


            AddresseeClient adc            = new AddresseeClient();
            string          emailpartition = AddresseeClient.GetPartitionKeyForEmail(email);
            Addressee       a = adc.GetByPartitionAndRowKey(emailpartition, email);
            if (a == null)
            {
                adc.AddNewItem(new Addressee(email.ToLower())
                {
                    Name = firstname, Email = email.ToLower(),
                });

                UserProfileClient upc     = new UserProfileClient();
                UserProfile       profile = new UserProfile(email.ToLower())
                {
                    Gender       = gender,
                    Salutation   = salutation,
                    FirstName    = firstname,
                    LastName     = lastname,
                    Email        = email,
                    Unsubscribed = false,
                    Zip          = zip,
                    Address1     = address,
                    City         = city,
                    State        = state,
                    Phone        = phone,
                    CampaignId   = campaign,

                    GradYear  = gradyear,
                    EduIntent = eduintent
                };
                profile.PopulateCityAndState();
                profile.SetTestResults(Request);
                profile.SetImportantThings(Request);
                profile.SetRecommendations(recommendations);
                profile.SetCareerChoices(data);
                upc.AddNewItem(profile);
            }

            WelcomeEmail.Send(Request, firstname, email, mode == "external");

            Response.Cookies["recordsubmitted"].Value   = "1";
            Response.Cookies["recordsubmitted"].Expires = DateTime.UtcNow.AddDays(90);

            Response.Cookies["ascv"].Value   = "0.20";
            Response.Cookies["ascv"].Expires = DateTime.UtcNow.AddDays(90);

            ViewBag.ThanksFlag = false;

            return(View());
        }
        private string SubmitForm(FormCollection collection, string target)
        {
            string submissionResult;
            string campaignid;
            string url;
            string ipaddress = RandomHelper.Instance.Next(1, 256) + "." + RandomHelper.Instance.Next(0, 256) + "." + RandomHelper.Instance.Next(0, 256) + "." + RandomHelper.Instance.Next(1, 256);

            if (target == "school")
            {
                campaignid = "13601764";
                url        = "http://explore-schools.com/affiliate/submit/";
            }
            else
            {
                campaignid = "13601765";
                url        = "http://explore-schools.com/affiliate/submit/";
            }
            string        submit = collection["submit"] != "true" ? "false" : "true";
            List <string> output = new List <string>();

            foreach (var key in collection.AllKeys)
            {
                if (key.ToLower() == "educationlevel")
                {
                    output.Add(new StringBuilder("education_level" + "=" + HttpUtility.UrlEncode(collection[key])).ToString());
                }
                else if (key.ToLower() == "client")
                {
                    output.Add(new StringBuilder("client_id" + "=" + HttpUtility.UrlEncode(collection[key])).ToString());
                }
                else if (key.ToLower() == "submit")
                {
                    continue;
                }
                output.Add(new StringBuilder(key + "=" + HttpUtility.UrlEncode(collection[key])).ToString());
            }
            string result = new StringBuilder("campaign_id=" + campaignid + "&id=1727" + "&ip=" + ipaddress + "&" + string.Join("&", output)).ToString();

            if (submit == "true")
            {
                //submissionResult = "test";
                submissionResult = SubmitLead(result, url);
            }
            else
            {
                submissionResult = "Filtered";
            }
            //return submissionResult;
            //=================================================================================================================================================================================

            String strPost = result;

            string clientid   = FormValue(collection, "client", "");
            string formid     = FormValue(collection, "form_id", "");
            string clienttype = clientid.StartsWith("SC") ? "Direct" : "Network";
            string campuskey  = FormValue(collection, "campus_key", "");
            string programkey = FormValue(collection, "program_key", "");

            string salutation = FormValue(collection, "salutation", "").Trim().ToProperCase();
            string gender     = salutation.ToLower() == "mr" ? "M" : "F";
            string firstname  = FormValue(collection, "firstname", "GET THIS");
            string lastname   = FormValue(collection, "lastname", "GET THIS");

            string email    = FormValue(collection, "email", "GET THIS").Trim().ToLower();
            string zip      = FormValue(collection, "zip", "GET THIS");
            string phone    = FormValue(collection, "phone", "GET THIS").Replace(".", "").Replace(" ", "").Replace("-", "").Replace("(", "").Replace(")", "");
            string address1 = FormValue(collection, "address1", "GET THIS");
            string city     = FormValue(collection, "city", "");
            string state    = FormValue(collection, "state", "");

            string educationlevel = FormValue(collection, "education_level", "SC");
            string eduintent      = FormValue(collection, "edu_intent", "YES");
            string military       = FormValue(collection, "military", "None");
            string gradyear       = FormValue(collection, "gradyear", "GET THIS");
            string sourceform     = FormValue(collection, "sourceform", "");

            string dobyear = FormValue(collection, "dobyear", "");

            Random rnd      = new Random(DateTime.Now.Millisecond);
            int    dobmonth = rnd.Next(1, 13);
            int    dobday   = rnd.Next(1, 29);

            string schoolvariables = "";

            if (Request.Cookies["schoolvariables"] != null)
            {
                schoolvariables = HttpUtility.UrlDecode(Request.Cookies["schoolvariables"].Value);
            }

            //GA variable
            string utmsource   = FromCookie("utm_source"),
                   utmcampaign = FromCookie("utm_campaign"),
                   utmcontent  = FromCookie("utm_content"),
                   utmterm     = FromCookie("utm_term");

            //Advertise.com variables
            string advertise_affsub        = FromCookie("AFFSUB"),
                   advertise_affiliate     = FromCookie("AFFILIATE"),
                   advertise_country       = FromCookie("COUNTRY"),
                   advertise_countrycode   = FromCookie("COUNTRYCODE"),
                   advertise_geo           = FromCookie("GEO"),
                   advertise_subid         = FromCookie("SUBID"),
                   advertise_terms_html_kw = FromCookie("TERMS_HTML_KW"),
                   advertise_terms         = FromCookie("TERMS");
            StringBuilder sbtestresults    = new StringBuilder();
            string        testresults      = "";

            if (Request.Cookies["testresults"] != null)
            {
                testresults = CookieDecoder.DecodeCookieCharacters(Request.Cookies["testresults"].Value);
            }

            string recommendations = "";

            if (Request.Cookies["recommendations"] != null)
            {
                recommendations = CookieDecoder.DecodeCookieCharacters(Request.Cookies["recommendations"].Value);
            }

            string careerChoicesJson = GetCareerChoicesJson();
            string data = "{\"careerchoices\":" + careerChoicesJson + "}";

            //Update the record with address
            DelayedRecordClient drc = new DelayedRecordClient();
            //First check if delayed record already exists for this email
            DelayedRecord dr = drc.GetByRowKey(email.FormatEmailAsProgrammaticId());

            if (dr != null)
            {
                if (dr.Address1 != address1)
                {
                    dr.Address1  = address1;
                    dr.EduIntent = "YES";
                    drc.Update(dr);
                }
            }
            SkillCowRequestSubmissionClient rsc = new SkillCowRequestSubmissionClient();

            rsc.AddNewItem(new SkillCowRequestSubmission
            {
                Salutation       = salutation,
                Name             = (firstname + " " + lastname).Trim(),
                Zip              = zip,
                Email            = email,
                Address1         = address1,
                City             = city,
                State            = state,
                Phone            = phone,
                IP               = ipaddress,
                Mode             = "CareerThesaurus",
                CampaignId       = campaignid,
                TestResults      = testresults,
                SourceForm       = target,
                GradYear         = gradyear,
                EduIntent        = "YES",
                Recommendations  = recommendations,
                ClientId         = clientid,
                FormId           = formid,
                CampusKey        = campuskey,
                ProgramKey       = programkey,
                Gender           = gender,
                SubmissionResult = submissionResult,
                Data             = data,
                UtmSource        = utmsource,
                UtmCampaign      = utmcampaign,
                UtmContent       = utmcontent,
                UtmTerm          = utmterm,
                PostedString     = strPost,
                ClientType       = clienttype
            });

            AddresseeClient adc            = new AddresseeClient();
            string          emailpartition = AddresseeClient.GetPartitionKeyForEmail(email);
            Addressee       a = adc.GetByPartitionAndRowKey(emailpartition, email);

            if (a == null)
            {
                adc.AddNewItem(new Addressee(email.ToLower())
                {
                    Name = firstname, Email = email.ToLower()
                });

                UserProfileClient upc     = new UserProfileClient();
                UserProfile       profile = new UserProfile(email.ToLower())
                {
                    Gender       = gender,
                    Salutation   = salutation,
                    FirstName    = firstname,
                    LastName     = lastname,
                    Email        = email,
                    Unsubscribed = false,
                    Zip          = zip,
                    Address1     = address1,
                    City         = city,
                    State        = state,
                    Phone        = phone,
                    CampaignId   = campaignid,
                    GradYear     = gradyear,
                    EduIntent    = "YES"
                };
                profile.PopulateCityAndState();
                profile.SetTestResults(Request);
                profile.SetImportantThings(Request);
                upc.AddNewItem(profile);
            }

            //============================================================================================================================================================================================
            return(submissionResult);
        }