public ActionResult Index()
        {
            LoyaltyDetailRewardOptIn optInRecord = new LoyaltyDetailRewardOptIn();

            optInRecord.LoyaltyDetailRewardSKUGroupIDs = Request.QueryString["utm_source"];
            optInRecord.LinkSource      = Request.QueryString["utm_medium"];
            optInRecord.Campaign        = Request.QueryString["utm_campaign"];
            optInRecord.VendorPromoCode = Request.QueryString["promoCode"];

            if (optInRecord.LoyaltyDetailRewardSKUGroupIDs == null)
            {
                optInRecord.LoyaltyDetailRewardSKUGroupIDs = "1017372,1017370,1017371,1017555,1017556,1017539,1017538,1017537,1017540,1017541";
            }
            if (optInRecord.Campaign == null)
            {
                optInRecord.Campaign = "none";
            }
            if (optInRecord.VendorPromoCode == null)
            {
                optInRecord.VendorPromoCode = "none";
            }

            Session["LDROptIn"] = optInRecord;
            return(View());
        }
        // check LoyaltyDetailRewardsOptIn_T_EC for MobileNumber to check for prior optin
        public int CheckForLDROptIn(Card card)
        {
            using (LoyayContext context = new LoyayContext())
            {
                var priorOptIn = new LoyaltyDetailRewardOptIn();
                priorOptIn = context.LoyaltyDetailRewardOptIns
                             .Where(o => o.MobilePhone == card.CH_MPHONE)
                             .Where(o => o.LoyaltyDetailRewardSKUGroupID == 1017372 ||
                                    o.LoyaltyDetailRewardSKUGroupID == 1017370 ||
                                    o.LoyaltyDetailRewardSKUGroupID == 1017371 ||
                                    o.LoyaltyDetailRewardSKUGroupID == 1017555 ||
                                    o.LoyaltyDetailRewardSKUGroupID == 1017556 ||
                                    o.LoyaltyDetailRewardSKUGroupID == 1017539 ||
                                    o.LoyaltyDetailRewardSKUGroupID == 1017538 ||
                                    o.LoyaltyDetailRewardSKUGroupID == 1017537 ||
                                    o.LoyaltyDetailRewardSKUGroupID == 1017540 ||
                                    o.LoyaltyDetailRewardSKUGroupID == 1017541)
                             .FirstOrDefault();

                if (priorOptIn == null)
                {
                    return(0);
                }
                else
                {
                    return(-1);
                }
            }
        }
        // Enrolls in either FSR or the combo-club for Reward Spot members
        public void EnrollFreshSpotRewards(Card card)
        {
            try
            {
                LoyaltyDetailRewardOptIn optIn = new LoyaltyDetailRewardOptIn();
                if (Session["LDROptIn"] != null)
                {
                    optIn = Session["LDROptIn"] as LoyaltyDetailRewardOptIn;
                }

                using (SqlConnection conn = new SqlConnection(connectionString))
                {
                    using (SqlCommand cmd = new SqlCommand())
                    {
                        cmd.Connection  = conn;
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.CommandText = "LoyaltyDetailRewardOptIn_S_EC";

                        cmd.Parameters.Add("@LoyaltyDetailRewardSKUGroupIDs", SqlDbType.VarChar).Value = optIn.LoyaltyDetailRewardSKUGroupIDs;
                        cmd.Parameters.Add("@CardID", SqlDbType.VarChar).Value     = card.CardID.ToString();
                        cmd.Parameters.Add("@LinkSource", SqlDbType.VarChar).Value = "FSRWebsite";
                        cmd.Parameters.Add("@Campaign", SqlDbType.VarChar).Value   = optIn.Campaign.ToString();
                        cmd.Parameters.Add("@PromoCode", SqlDbType.VarChar).Value  = optIn.VendorPromoCode.ToString();

                        conn.Open();

                        cmd.CommandTimeout = 240;
                        cmd.ExecuteNonQuery();
                    }
                }
            }
            catch (Exception ex)
            {
                new HomeController().LogError(ex);
            }
        }