コード例 #1
0
        public ActionResult four_for_1_spring2(string SubmitButton, FormCollection form, ShippingModels.ShippingBillingOrder shipping)
        {
            ViewData["StatesList"] = UtilitiesModels.GetStateNameList();
            ViewData["GenderList"] = UtilitiesModels.GetChildGenderNameList();
            ViewData["MonthList"] = UtilitiesModels.GetMonthNameList();
            ViewData["YearList"] = UtilitiesModels.GetCardExpiryYearList();
            OrderProcess oProcess = new OrderProcess();
            CommonMethods oComm = new CommonMethods();
            CommonModels oCom = new CommonModels();
            OrderVariables oVariables = new OrderVariables();
            string cart_details, conf_pg_tac, total = "";
            string shipall = "false";
            string template = "";
            string pixel = "";
            try
            {
                if (!string.IsNullOrEmpty(SubmitButton))
                {
                    switch (SubmitButton.ToLower())
                    {
                        case "rush my books":
                            oVariables = oProcess.GetOfferAndPageDetails("fosina-seuss-4for1-secure-activity");
                            shipping.stepNumber = 1;
                            var offerService = new OfferService();
                            oVariables = offerService.MapQueryStringToOrderVariables(oVariables: oVariables);
                            oVariables = ShippingModels.AssignShippingBillingToOrderVariables(oVariables, shipping);
                            oVariables = oProcess.OrderSubmit(oVariables);
                            if (oVariables != null)
                            {
                                if (oVariables.order_id > 0)
                                {
                                    Session.Add("NewOrderDetails", oVariables);
                                    if (oVariables.upsellId != 0)
                                    {
                                        Session["fireFaceBookConfirmationPixel"] = "false";
                                        return RedirectToAction("OrderDetails", "AdditionalOffers");
                                    }
                                    else
                                    {
                                        Session["fireFaceBookConfirmationPixel"] = "true";
                                        return RedirectToAction("Confirmation", "Home");
                                    }
                                }
                                else
                                {
                                    if (oVariables.err.Length >= 0)
                                    {
                                        if ((oVariables.order_status == "X") || (oVariables.order_status == "F"))
                                        {
                                            Session.Add("NewOrderDetails", oVariables);
                                            return RedirectToAction("orderstatus", "Home");
                                        }
                                        else if (oVariables.err.Length > 0)
                                        {
                                            ViewBag.ErrorMsg = oVariables.err;
                                            oVariables.err = oVariables.err.Replace("<br>", "\\r\\n");
                                        }
                                        else if ((oVariables.order_status == "N") || (oVariables.redirect_page.Length > 0))
                                        {
                                            Session.Add("NewSBMDetails", oVariables);
                                            shipping.stepNumber = 2;
                                            #region LoadPaymentSection
                                            try
                                            {
                                                if (Session["NewSBMDetails"] != null)
                                                {
                                                    oVariables = (OrderVariables)Session["NewSBMDetails"];
                                                    Dictionary<string, string> d = oCom.GetOfferCreatives(oVariables);
                                                    ViewBag.HeaderImageSrc = oComm.GetDictionaryValue("payment_header", d);
                                                    if ((string)Request.QueryString["shipall"] != null) { shipall = (string)Request.QueryString["shipall"]; }
                                                    if ((string)Request.QueryString["template"] != null) { template = (string)Request.QueryString["template"]; }
                                                    string cartId = oVariables.cart_id.ToString();
                                                    conf_pg_tac = oVariables.PageVars[0].conf_pg_tac;
                                                    cart_details = oCom.ResponsivePayment_GiftingProducts(oVariables, Convert.ToBoolean(shipall), template);
                                                    total = String.Format("{0:c}", oVariables.total_amt + oVariables.tax_amt + oVariables.total_sah);
                                                    ViewBag.IsBonusSelected = false;
                                                    if (oVariables.bonus_option == true)
                                                    {
                                                        ViewBag.IsBonusSelected = true;
                                                    }
                                                    ViewBag.CartSummary = cart_details;
                                                    ViewBag.Cart = cartId;
                                                    ViewBag.Total = total;
                                                    ViewBag.ConfPgTAC = conf_pg_tac;
                                                    return View();
                                                }
                                                else
                                                {
                                                    return RedirectToAction("four_for_1_spring", "seuss", routeValues: ViewContextExtensions.OptionalParamters(Request.QueryString));
                                                }
                                            }
                                            catch (Exception ex)
                                            {
                                                oCom.SendEmail("Exception Raised in EM Landers Payment Page - " + ex.Message.ToString());
                                                return View();
                                            }
                                            finally
                                            {
                                                oComm = null;
                                                oVariables = null;
                                            }
                                            #endregion
                                        }
                                        else
                                        {
                                            ViewBag.ErrorMsg = oVariables.err;
                                            oVariables.err = oVariables.err.Replace("<br>", "\\r\\n");
                                        }
                                    }
                                }
                            }
                            else
                            {
                                //page_log += "Order is NOT processed, Order Process returned NULL.<br>";
                                Session["NewSBMDetails"] = null;
                                return RedirectToAction("orderstatus", "Home");
                            }
                            break;

                        case "submit order":
                            #region Payment Submit
                            if (!string.IsNullOrEmpty(shipping.SecurityCaptch) && Session["rndtext"] != null)
                            {
                                string strCaptch = Session["rndtext"] as string;
                                if (!strCaptch.Equals(shipping.SecurityCaptch))
                                {
                                    ViewBag.ErrorMsg = "Invalid Security Captch.";
                                    // return View();
                                }
                            }
                            else
                            {
                                //if (string.IsNullOrEmpty(billing.SecurityCaptch))
                                //{
                                ViewBag.ErrorMsg = "Security Captch is required.";
                                // return View();
                                //}
                            }

                            if (Session["ShippingDetails"] != null)
                                oVariables = Session["ShippingDetails"] as OrderVariables;

                            try
                            {
                                if (Session["NewSBMDetails"] != null)
                                {
                                    oVariables = (OrderVariables)Session["NewSBMDetails"];

                                    if (oVariables != null)
                                    {
                                        if (ViewBag.ErrorMsg != null && ViewBag.ErrorMsg != "")
                                        {
                                            //Setting values if page is getting back to the payment view only.
                                            Dictionary<string, string> d = oCom.GetOfferCreatives(oVariables);
                                            ViewBag.HeaderImageSrc = oCom.GetDictionaryValue("payment_header", d);
                                            if ((string)Request.QueryString["shipall"] != null) { shipall = (string)Request.QueryString["shipall"]; }
                                            if ((string)Request.QueryString["template"] != null) { template = (string)Request.QueryString["template"]; }
                                            string cartId = oVariables.cart_id.ToString();
                                            conf_pg_tac = oVariables.PageVars[0].conf_pg_tac;
                                            cart_details = oCom.ResponsivePayment_GiftingProducts(oVariables, Convert.ToBoolean(shipall), template);
                                            total = String.Format("{0:c}", oVariables.total_amt + oVariables.tax_amt + oVariables.total_sah);
                                            ViewBag.IsBonusSelected = false;
                                            if (oVariables.bonus_option == true)
                                            {
                                                ViewBag.IsBonusSelected = true;
                                            }
                                            ViewBag.CartSummary = cart_details;
                                            ViewBag.Cart = cartId;
                                            ViewBag.Total = total;
                                            ViewBag.ConfPgTAC = conf_pg_tac;
                                            // billing.SecurityCaptch = "";
                                            // ViewData.Model = billing;
                                            //return View(ViewData.Model);
                                            return View();
                                        }

                                        shipping.stepNumber = 2;
                                        oVariables = ShippingModels.AssignShippingBillingToOrderVariables(oVariables, shipping);
                                        oVariables = oProcess.OrderSubmit(oVariables);
                                        if (oVariables != null)
                                        {
                                            if (oVariables.order_id > 0)
                                            {
                                                Session["NewSBMDetails"] = null;
                                                Session.Add("NewOrderDetails", oVariables);
                                                if (oVariables.upsellId != 0)
                                                {
                                                    Session["fireFaceBookConfirmationPixel"] = "false";
                                                    return RedirectToAction("OrderDetails", "AdditionalOffers");
                                                }
                                                else
                                                {
                                                    Session["fireFaceBookConfirmationPixel"] = "true";
                                                    return RedirectToAction("Confirmation", "Home");
                                                }
                                            }
                                            else
                                            {
                                                if (oVariables.err.Length > 0)
                                                {
                                                    if ((oVariables.order_status == "X") || (oVariables.order_status == "F"))
                                                    {
                                                        Session["NewSBMDetails"] = null;
                                                        Session.Add("NewOrderDetails", oVariables);
                                                        return RedirectToAction("orderstatus", "Home");
                                                    }
                                                    else
                                                    {
                                                        Session.Add("NewSBMDetails", oVariables);
                                                        ViewBag.ErrorMsg = oVariables.err;
                                                        oVariables.err = oVariables.err.Replace("<br>", "\\r\\n");
                                                    }
                                                }
                                                else if (oVariables.isSoftDeclined)
                                                {
                                                    Session["NewSBMDetails"] = null;
                                                    return RedirectToAction("ThankYou", "home");
                                                }
                                                //Setting values if page is getting back to the payment view only.
                                                Dictionary<string, string> d = oCom.GetOfferCreatives(oVariables);
                                                ViewBag.HeaderImageSrc = oComm.GetDictionaryValue("payment_header", d);
                                                if ((string)Request.QueryString["shipall"] != null) { shipall = (string)Request.QueryString["shipall"]; }
                                                if ((string)Request.QueryString["template"] != null) { template = (string)Request.QueryString["template"]; }
                                                string cartId = oVariables.cart_id.ToString();
                                                conf_pg_tac = oVariables.PageVars[0].conf_pg_tac;
                                                cart_details = oCom.ResponsivePayment_GiftingProducts(oVariables, Convert.ToBoolean(shipall), template);
                                                total = String.Format("{0:c}", oVariables.total_amt + oVariables.tax_amt + oVariables.total_sah);
                                                ViewBag.IsBonusSelected = false;
                                                if (oVariables.bonus_option == true)
                                                {
                                                    ViewBag.IsBonusSelected = true;
                                                }
                                                ViewBag.CartSummary = cart_details;
                                                ViewBag.Cart = cartId;
                                                ViewBag.Total = total;
                                                ViewBag.ConfPgTAC = conf_pg_tac;
                                            }
                                        }
                                        else
                                        {
                                            return RedirectToAction("orderstatus", "Home");
                                        }
                                    }
                                    return View();
                                }
                                else
                                {
                                    return RedirectToAction("four_for_1_spring2", "seuss", routeValues: ViewContextExtensions.OptionalParamters(Request.QueryString));
                                }

                            }
                            catch (Exception ex)
                            {
                                oCom.SendEmail("Exception Raised in EM Landers Payment Page (Submit) - " + ex.Message.ToString());
                                return View();
                            }
                            finally
                            {
                                oComm = null;
                                oVariables = null;
                                oProcess = null;
                            }
                            #endregion
                            break;
                    }
                }
            }
            catch (Exception ex)
            {
                string page_log = "Exception raised. Exception: " + ex.Message.ToString() + "<br>";
                string s = "";// oCom.LogBrowserCapabilities(Request.Browser);
                oCom.SendEmail(HttpContext.Request.Url.ToString() + "<br>ex.message = " + ex.Message.ToString() + "<br> Additional Information - " + page_log + ".<br> Browser Details....<br>" + s);
                return View();
            }
            finally
            {
                oVariables = null;
                oComm = null;
                oProcess = null;
            }
            return View();
        }