Пример #1
0
        public ActionResult Confirm()
        {
            //Assign value to form field from session
            CustomCart cart       = new CustomCart().Current();
            CustomForm customForm = new CustomForm();

            customForm.FirstName = cart.BillingFirstnames;
            customForm.LastName  = cart.BillingSurname;
            customForm.Address1  = cart.BillingAddress1;
            customForm.Address2  = cart.BillingAddress2;
            customForm.City      = cart.BillingCity;
            customForm.PostCode  = cart.BillingPostCode;
            customForm.Country   = cart.BillingCountry;
            customForm.Phone     = cart.Phone;
            customForm.DOB       = Convert.ToDateTime(cart.DOB);

            SagePayFormIntegration sagePayFormIntegration = new SagePayFormIntegration();

            IFormPayment request = sagePayFormIntegration.FormPaymentRequest();

            SetSagePayAPIData(request);

            var errors = sagePayFormIntegration.Validation(request);

            if (errors == null || errors.Count == 0)
            {
                sagePayFormIntegration.ProcessRequest(request);
                ViewBag.Crypt = request.Crypt;
            }
            else
            {
                ViewBag.Error = "Some error occurred";
            }
            return(View(customForm));
        }
        public virtual CustomCart CustomCartFromDataRow(DataRow dr)
        {
            if (dr == null)
            {
                return(null);
            }
            CustomCart entity = new CustomCart();

            entity.CustomCartRecId              = (System.Int32)dr["CustomCartRecID"];
            entity.CustomerId                   = (System.Int32)dr["CustomerID"];
            entity.PackId                       = (System.Int32)dr["PackID"];
            entity.ShoppingCartRecId            = (System.Int32)dr["ShoppingCartRecID"];
            entity.ProductSku                   = dr["ProductSKU"].ToString();
            entity.ProductWeight                = (System.Decimal)dr["ProductWeight"];
            entity.ProductId                    = (System.Int32)dr["ProductID"];
            entity.VariantId                    = (System.Int32)dr["VariantID"];
            entity.Quantity                     = (System.Int32)dr["Quantity"];
            entity.ChosenColor                  = dr["ChosenColor"].ToString();
            entity.ChosenColorSkuModifier       = dr["ChosenColorSKUModifier"].ToString();
            entity.ChosenSize                   = dr["ChosenSize"].ToString();
            entity.ChosenSizeSkuModifier        = dr["ChosenSizeSKUModifier"].ToString();
            entity.CartType                     = (System.Int32)dr["CartType"];
            entity.OriginalRecurringOrderNumber = dr["OriginalRecurringOrderNumber"] == DBNull.Value?(System.Int32?)null : (System.Int32?)dr["OriginalRecurringOrderNumber"];
            entity.ExtensionData                = dr["ExtensionData"].ToString();
            entity.CreatedOn                    = (System.DateTime)dr["CreatedOn"];
            return(entity);
        }
Пример #3
0
 public ActionResult Index(CustomForm model)
 {
     if (ModelState.IsValid)
     {
         CustomForm form = new CustomForm();
         CustomCart cart = new CustomCart();
         cart.Description        = model.Description != null ? model.Description : form.getDefaultDescription();
         cart.BillingSurname     = model.LastName;
         cart.BillingFirstnames  = model.FirstName;
         cart.BillingAddress1    = model.Address1;
         cart.BillingAddress2    = model.Address2;
         cart.BillingCity        = model.City;
         cart.BillingCountry     = form.getDefaultCountry();
         cart.DeliverySurname    = model.LastName;
         cart.DeliveryFirstnames = model.FirstName;
         cart.DeliveryAddress1   = model.Address1;
         cart.DeliveryAddress2   = model.Address2;
         cart.DeliveryCity       = model.City;
         cart.DeliveryCountry    = form.getDefaultCountry();
         cart.BillingPostCode    = model.PostCode;
         cart.DeliveryPostCode   = model.PostCode;
         cart.BasketXml          = form.getDefaultItemXML();
         cart.Phone = model.Phone;
         cart.DOB   = model.DOB.ToShortDateString();
         Session[cart.CURRENT_USER_SHOPPINGCART] = cart;
         return(RedirectToAction("Confirm"));
     }
     return(View(model));
 }
        public virtual CustomCart UpdateCustomCart(CustomCart entity)
        {
            if (entity.IsTransient())
            {
                return(entity);
            }
            CustomCart other = GetCustomCart(entity.CustomCartRecId);

            if (entity.Equals(other))
            {
                return(entity);
            }
            string sql = @"Update CustomCart set  [CustomerID]=@CustomerID
							, [PackID]=@PackID
							, [ShoppingCartRecID]=@ShoppingCartRecID
							, [ProductSKU]=@ProductSKU
							, [ProductWeight]=@ProductWeight
							, [ProductID]=@ProductID
							, [VariantID]=@VariantID
							, [Quantity]=@Quantity
							, [ChosenColor]=@ChosenColor
							, [ChosenColorSKUModifier]=@ChosenColorSKUModifier
							, [ChosenSize]=@ChosenSize
							, [ChosenSizeSKUModifier]=@ChosenSizeSKUModifier
							, [CartType]=@CartType
							, [OriginalRecurringOrderNumber]=@OriginalRecurringOrderNumber
							, [ExtensionData]=@ExtensionData
							, [CreatedOn]=@CreatedOn 
							 where CustomCartRecID=@CustomCartRecID"                            ;

            SqlParameter[] parameterArray = new SqlParameter[] {
                new SqlParameter("@CustomCartRecID", entity.CustomCartRecId)
                , new SqlParameter("@CustomerID", entity.CustomerId)
                , new SqlParameter("@PackID", entity.PackId)
                , new SqlParameter("@ShoppingCartRecID", entity.ShoppingCartRecId)
                , new SqlParameter("@ProductSKU", entity.ProductSku ?? (object)DBNull.Value)
                , new SqlParameter("@ProductWeight", entity.ProductWeight)
                , new SqlParameter("@ProductID", entity.ProductId)
                , new SqlParameter("@VariantID", entity.VariantId)
                , new SqlParameter("@Quantity", entity.Quantity)
                , new SqlParameter("@ChosenColor", entity.ChosenColor ?? (object)DBNull.Value)
                , new SqlParameter("@ChosenColorSKUModifier", entity.ChosenColorSkuModifier ?? (object)DBNull.Value)
                , new SqlParameter("@ChosenSize", entity.ChosenSize ?? (object)DBNull.Value)
                , new SqlParameter("@ChosenSizeSKUModifier", entity.ChosenSizeSkuModifier ?? (object)DBNull.Value)
                , new SqlParameter("@CartType", entity.CartType)
                , new SqlParameter("@OriginalRecurringOrderNumber", entity.OriginalRecurringOrderNumber ?? (object)DBNull.Value)
                , new SqlParameter("@ExtensionData", entity.ExtensionData ?? (object)DBNull.Value)
                , new SqlParameter("@CreatedOn", entity.CreatedOn)
            };
            SqlHelper.ExecuteNonQuery(this.ConnectionString, CommandType.Text, sql, parameterArray);
            return(GetCustomCart(entity.CustomCartRecId));
        }
Пример #5
0
        private void SetSagePayAPIData(IFormPayment request)
        {
            var        isCollectRecipientDetails = SagePaySettings.IsCollectRecipientDetails;
            CustomCart cart = new CustomCart().Current();

            request.VpsProtocol     = SagePaySettings.ProtocolVersion;
            request.TransactionType = SagePaySettings.DefaultTransactionType;
            request.Vendor          = SagePaySettings.VendorName;
            request.VendorTxCode    = SagePayFormIntegration.GetNewVendorTxCode();

            request.Amount            = 1; //Custom value set
            request.Currency          = SagePaySettings.Currency;
            request.SuccessUrl        = SagePaySettings.SiteFqdn + "Payment/Result?customParams=Transaction Details For Success";
            request.FailureUrl        = SagePaySettings.SiteFqdn + "Payment/Result?customParams=Transaction Details For Failure";
            request.Description       = cart.Description;
            request.BillingSurname    = cart.BillingSurname;
            request.BillingFirstnames = cart.BillingFirstnames;
            request.BillingAddress1   = cart.BillingAddress1 + " " + cart.BillingAddress2;
            request.BillingCity       = cart.BillingCity;
            request.BillingCountry    = cart.BillingCountry;

            request.DeliverySurname    = cart.DeliverySurname;
            request.DeliveryFirstnames = cart.DeliveryFirstnames;
            request.DeliveryAddress1   = cart.DeliveryAddress1 + " " + cart.DeliveryAddress2;
            request.DeliveryCity       = cart.DeliveryCity;
            request.DeliveryCountry    = cart.DeliveryCountry;

            //Optional
            request.BillingPostCode  = cart.BillingPostCode;
            request.DeliveryPostCode = cart.DeliveryPostCode;
            request.BasketXml        = cart.BasketXml;

            request.VendorEmail  = SagePaySettings.VendorEmail;
            request.SendEmail    = SagePaySettings.SendEmail;
            request.EmailMessage = SagePaySettings.EmailMessage;

            request.AllowGiftAid     = SagePaySettings.AllowGiftAid;
            request.ApplyAvsCv2      = SagePaySettings.ApplyAvsCv2;
            request.Apply3dSecure    = SagePaySettings.Apply3dSecure;
            request.BillingAgreement = "";
            request.ReferrerId       = SagePaySettings.ReferrerID;
            request.SurchargeXml     = SagePaySettings.SurchargeXML;
            //set vendor data
            request.VendorData = "";
        }
Пример #6
0
        private void TranslateCustomPaymentMethods(Cart source, CustomCart customCart)
        {
            var payments = source.Components.OfType <PaymentComponent>().ToList();

            if (!payments.Any())
            {
                return;
            }

            foreach (var payment in payments)
            {
                if (payment is SimplePaymentComponent simplePayment)
                {
                    var simplePaymentInfo = this.EntityFactory.Create <SimplePaymentInfo>("SimplePayment");
                    simplePaymentInfo.ExternalId      = simplePayment.Id;
                    simplePaymentInfo.PaymentMethodID = simplePayment.PaymentMethod.EntityTarget;
                    simplePaymentInfo.Amount          = simplePayment.Amount.Amount;

                    customCart.Payment.Add(simplePaymentInfo);
                }
            }
        }
        protected void Page_Load(object sender, System.EventArgs e)
        {
            Response.CacheControl = "private";
            Response.Expires      = 0;
            Response.AddHeader("pragma", "no-cache");

            Customer ThisCustomer = ((AspDotNetStorefrontPrincipal)Context.User).ThisCustomer;

            int    PackID     = CommonLogic.QueryStringUSInt("PackID");
            int    ProductID  = CommonLogic.QueryStringUSInt("ProductID");
            int    CategoryID = CommonLogic.QueryStringUSInt("CategoryID");
            int    SectionID  = CommonLogic.QueryStringUSInt("SectionID");
            int    DeleteID   = CommonLogic.QueryStringUSInt("DeleteID");
            string SCartRecID = CommonLogic.QueryStringCanBeDangerousContent("cartrecid");

            if (DeleteID != 0)
            {
                CustomCart.DeleteItem(DeleteID, CartTypeEnum.ShoppingCart);
            }

            String url = SE.MakeProductAndEntityLink(CommonLogic.QueryStringCanBeDangerousContent("entityname"), PackID, CommonLogic.QueryStringUSInt("entityid"), "");

            Response.Redirect(url + CommonLogic.IIF(SCartRecID == "", "", "?cartrecid=" + SCartRecID));
        }
Пример #8
0
        private void TranslateAdditionalParties(Cart source, CustomCart customCart)
        {
            var additionalParties = source.Components.OfType <AdditionalPartiesComponent>().FirstOrDefault();

            additionalParties?.Parties.ForEach(party =>
            {
                var extendedPartyPolicy = party.Policies.OfType <ExtendedPartyPolicy>().FirstOrDefault();
                customCart.CustomParties.Add(new CustomParty()
                {
                    FirstName     = party.FirstName,
                    LastName      = party.LastName,
                    Address1      = party.Address1,
                    Address2      = party.Address2,
                    City          = party.City,
                    Country       = party.Country,
                    State         = party.State,
                    ZipPostalCode = party.ZipPostalCode,
                    IsCompany     = extendedPartyPolicy?.IsCompany ?? false,
                    Gender        = extendedPartyPolicy?.Gender,
                    Title         = extendedPartyPolicy?.Title,
                    Phone         = extendedPartyPolicy?.Phone
                });
            });
        }
Пример #9
0
 public CustomCart InsertCustomCart(CustomCart entity)
 {
     return(_iCustomCartRepository.InsertCustomCart(entity));
 }
Пример #10
0
 public CustomCart UpdateCustomCart(CustomCart entity)
 {
     return(_iCustomCartRepository.UpdateCustomCart(entity));
 }
Пример #11
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            if (AppLogic.AppConfigBool("GoNonSecureAgain"))
            {
                SkinBase.GoNonSecureAgain();
            }

            ProductID      = CommonLogic.QueryStringUSInt("ProductID");
            CategoryID     = CommonLogic.QueryStringUSInt("CategoryID");
            SectionID      = CommonLogic.QueryStringUSInt("SectionID");
            ManufacturerID = CommonLogic.QueryStringUSInt("ManufacturerID");
            DistributorID  = CommonLogic.QueryStringUSInt("DistributorID");
            GenreID        = CommonLogic.QueryStringUSInt("GenreID");
            VectorID       = CommonLogic.QueryStringUSInt("VectorID");

            if (ProductID == 0)
            {
                if (IsAddToCartPostBack)
                {
                    int    PackID                 = 0;
                    int    packProductID          = 0;
                    int    packVariantID          = 0;
                    int    packQuantity           = 0;
                    int    packProductTypeID      = 0;
                    bool   FromCart               = false;
                    int    packCartRecID          = 0;
                    String ChosenColor            = String.Empty;
                    String ChosenColorSKUModifier = String.Empty;
                    String ChosenSize             = String.Empty;
                    String ChosenSizeSKUModifier  = String.Empty;
                    String color      = string.Empty;
                    String size       = string.Empty;
                    String TextOption = CommonLogic.FormCanBeDangerousContent("TextOption");


                    for (int i = 0; i <= HttpContext.Current.Request.Form.Count - 1; i++)
                    {
                        if (HttpContext.Current.Request.Form.Keys[i].StartsWith("ProductID", StringComparison.InvariantCultureIgnoreCase))
                        {
                            packProductID = Localization.ParseUSInt(CommonLogic.FormCanBeDangerousContent("__EVENTARGUMENT").Split('_')[1]);
                        }
                        if (HttpContext.Current.Request.Form.Keys[i].StartsWith("VariantID", StringComparison.InvariantCultureIgnoreCase))
                        {
                            packVariantID = Localization.ParseUSInt(CommonLogic.FormCanBeDangerousContent("__EVENTARGUMENT").Split('_')[2]);
                        }

                        if (HttpContext.Current.Request.Form.Keys[i].StartsWith("PackID", StringComparison.InvariantCultureIgnoreCase))
                        {
                            PackID = Localization.ParseUSInt(CommonLogic.FormCanBeDangerousContent(HttpContext.Current.Request.Form.Keys[i]));
                            if (CommonLogic.FormCanBeDangerousContent(HttpContext.Current.Request.Form.Keys[i]).Contains(",") && PackID == 0)
                            {
                                PackID = Localization.ParseUSInt(CommonLogic.FormCanBeDangerousContent(HttpContext.Current.Request.Form.Keys[i]).Split(',')[0]);
                            }
                        }

                        if (HttpContext.Current.Request.Form.Keys[i].StartsWith("Quantity", StringComparison.InvariantCultureIgnoreCase) && !HttpContext.Current.Request.Form.Keys[i].StartsWith("Quantity_vldt", StringComparison.InvariantCultureIgnoreCase))
                        {
                            if (Localization.ParseUSInt(HttpContext.Current.Request.Form.Keys[i].Split('_')[2]) == packVariantID)
                            {
                                packQuantity = Localization.ParseUSInt(CommonLogic.FormCanBeDangerousContent(HttpContext.Current.Request.Form.Keys[i]));
                            }
                        }
                        if (HttpContext.Current.Request.Form.Keys[i].StartsWith("CartRecID", StringComparison.InvariantCultureIgnoreCase))
                        {
                            packCartRecID = Localization.ParseUSInt(CommonLogic.FormCanBeDangerousContent(HttpContext.Current.Request.Form.Keys[i]));
                        }
                        if (HttpContext.Current.Request.Form.Keys[i].StartsWith("Color", StringComparison.InvariantCultureIgnoreCase))
                        {
                            if (Localization.ParseUSInt(HttpContext.Current.Request.Form.Keys[i].Split('_')[2]) == packVariantID)
                            {
                                color = CommonLogic.FormCanBeDangerousContent(HttpContext.Current.Request.Form.Keys[i]).ToString();
                            }
                        }
                        if (HttpContext.Current.Request.Form.Keys[i].StartsWith("Size", StringComparison.InvariantCultureIgnoreCase))
                        {
                            if (Localization.ParseUSInt(HttpContext.Current.Request.Form.Keys[i].Split('_')[2]) == packVariantID)
                            {
                                size = CommonLogic.FormCanBeDangerousContent(HttpContext.Current.Request.Form.Keys[i]).ToString();
                            }
                        }
                        if (HttpContext.Current.Request.Form.Keys[i].StartsWith("ProductTypeID", StringComparison.InvariantCultureIgnoreCase))
                        {
                            if (Localization.ParseUSInt(HttpContext.Current.Request.Form.Keys[i].Split('_')[2]) == packVariantID)
                            {
                                packProductTypeID = Localization.ParseUSInt(CommonLogic.FormCanBeDangerousContent(HttpContext.Current.Request.Form.Keys[i]));
                            }
                        }
                    }


                    ThisCustomer.RequireCustomerRecord();
                    if (packQuantity == 0)
                    {
                        packQuantity = 1;
                    }
                    FromCart = (packCartRecID > 0);

                    if (color.Length != 0)
                    {
                        String[] ColorSel = color.Split(',');
                        try
                        {
                            ChosenColor = ColorSel[0];
                        }
                        catch { }
                        try
                        {
                            ChosenColorSKUModifier = ColorSel[1];
                        }
                        catch { }
                    }
                    if (ChosenColor.Length != 0)
                    {
                        ThisCustomer.ThisCustomerSession["ChosenColor"] = ChosenColor;
                    }


                    if (size.Length != 0)
                    {
                        String[] SizeSel = size.Split(',');
                        try
                        {
                            ChosenSize = SizeSel[0];
                        }
                        catch { }
                        try
                        {
                            ChosenSizeSKUModifier = SizeSel[1];
                        }
                        catch { }
                    }
                    if (ChosenSize.Length != 0)
                    {
                        ThisCustomer.ThisCustomerSession["ChosenSize"] = ChosenSize;
                    }

                    if (packQuantity > 0)
                    {
                        // add to custom cart:
                        if (FromCart)
                        {
                            CustomCart.AddItem(PackID, packProductID, packVariantID, packQuantity, ChosenColor, ChosenColorSKUModifier, ChosenSize, ChosenSizeSKUModifier, packCartRecID, ThisCustomer, CartTypeEnum.ShoppingCart);
                        }
                        else
                        {
                            CustomCart cart = new CustomCart(ThisCustomer, PackID, 1, CartTypeEnum.ShoppingCart);
                            cart.AddItem(packProductID, packVariantID, packQuantity, ChosenColor, ChosenColorSKUModifier, ChosenSize, ChosenSizeSKUModifier);
                        }
                    }

                    if (CommonLogic.QueryStringCanBeDangerousContent("UpdateCartPack") == "")
                    {
                        String url = "pb.aspx?type=" + packProductTypeID.ToString() + "&PackID=" + PackID.ToString() + "&ProductID=" + packProductID.ToString() + "&cartrecid=" + packCartRecID;

                        Response.Redirect(url + CommonLogic.IIF(FromCart, "?cartrecid=" + packCartRecID.ToString(), ""));
                        Response.Redirect(url);
                    }
                    else
                    {
                        Response.Redirect(ResolveClientUrl("~/shoppingcart.aspx"));
                    }
                }
            }
            String ActualSEName = string.Empty;

            using (SqlConnection dbconn = new SqlConnection(DB.GetDBConn()))
            {
                dbconn.Open();
                using (IDataReader rs = DB.GetRS(string.Format("select * from Product a with (NOLOCK) inner join (select a.ProductID, b.StoreID from Product a with (nolock) left join ProductStore b " +
                                                               "with (NOLOCK) on a.ProductID = b.ProductID) b on a.ProductID = b.ProductID where Deleted=0 and a.ProductID={0} and ({1}=0 or StoreID={2})", +
                                                               ProductID, CommonLogic.IIF(AppLogic.GlobalConfigBool("AllowProductFiltering") == true, 1, 0), AppLogic.StoreID()), dbconn))
                {
                    if (!rs.Read())
                    {
                        Response.Redirect(SE.MakeDriverLink("ProductNotFound"));
                    }
                    else
                    {
                        bool a = DB.RSFieldBool(rs, "Published");
                        if (!a)
                        {
                            Response.Redirect(SE.MakeDriverLink("ProductNotFound"));
                        }
                    }

                    String SENameINURL = CommonLogic.QueryStringCanBeDangerousContent("SEName");
                    ActualSEName = SE.MungeName(DB.RSField(rs, "SEName"));
                    if (ActualSEName != SENameINURL)
                    {
                        String NewURL = AppLogic.GetStoreHTTPLocation(false, false) + SE.MakeProductLink(ProductID, ActualSEName);

                        string QStr  = "?";
                        bool   first = true;
                        for (int i = 0; i < Request.QueryString.Count; i++)
                        {
                            string key = Request.QueryString.GetKey(i);
                            if ((key.Equals("productid", StringComparison.InvariantCultureIgnoreCase)) == false && (key.Equals("sename", StringComparison.InvariantCultureIgnoreCase)) == false)
                            {
                                if (!first)
                                {
                                    QStr += "&";
                                }
                                QStr += key + "=" + Request.QueryString[i];
                                first = false;
                            }
                        }
                        if (QStr.Length > 1)
                        {
                            NewURL += QStr;
                        }

                        HttpContext.Current.Response.Write("<html><head><title>Object Moved</title></head><body><b>Object moved to <a href=\"" + NewURL + "\">HERE</a></b></body></html>");
                        Response.Status = "301 Moved Permanently";
                        Response.AddHeader("Location", NewURL);
                        HttpContext.Current.Response.End();
                    }


                    #region Vortx Mobile Xml Package Modification
                    m_XmlPackage = Vortx.MobileFramework.MobileXmlPackageController.XmlPackageHook(DB.RSField(rs, "XmlPackage").ToLowerInvariant(), ThisCustomer);
                    #endregion
                    IsAKit  = DB.RSFieldBool(rs, "IsAKit");
                    IsAPack = DB.RSFieldBool(rs, "IsAPack");
                    if (m_XmlPackage.Length == 0)
                    {
                        if (IsAKit)
                        {
                            m_XmlPackage = AppLogic.ro_DefaultProductKitXmlPackage; // provide a default
                        }
                        else if (IsAPack)
                        {
                            m_XmlPackage = AppLogic.ro_DefaultProductPackXmlPackage; // provide a default
                        }
                        else
                        {
                            m_XmlPackage = AppLogic.ro_DefaultProductXmlPackage; // provide a default
                        }
                    }
                    RequiresReg = DB.RSFieldBool(rs, "RequiresRegistration");
                    ProductName = DB.RSFieldByLocale(rs, "Name", ThisCustomer.LocaleSetting);

                    CategoryHelper     = AppLogic.LookupHelper("Category", 0);
                    SectionHelper      = AppLogic.LookupHelper("Section", 0);
                    ManufacturerHelper = AppLogic.LookupHelper("Manufacturer", 0);
                    DistributorHelper  = AppLogic.LookupHelper("Distributor", 0);
                    GenreHelper        = AppLogic.LookupHelper("Genre", 0);
                    VectorHelper       = AppLogic.LookupHelper("Vector", 0);

                    String SEName = String.Empty;
                    if (DB.RSFieldByLocale(rs, "SETitle", ThisCustomer.LocaleSetting).Length == 0)
                    {
                        SETitle = Security.HtmlEncode(AppLogic.AppConfig("StoreName") + " - " + ProductName);
                    }
                    else
                    {
                        SETitle = DB.RSFieldByLocale(rs, "SETitle", ThisCustomer.LocaleSetting);
                    }
                    if (DB.RSFieldByLocale(rs, "SEDescription", ThisCustomer.LocaleSetting).Length == 0)
                    {
                        SEDescription = Security.HtmlEncode(ProductName);
                    }
                    else
                    {
                        SEDescription = DB.RSFieldByLocale(rs, "SEDescription", ThisCustomer.LocaleSetting);
                    }
                    if (DB.RSFieldByLocale(rs, "SEKeywords", ThisCustomer.LocaleSetting).Length == 0)
                    {
                        SEKeywords = Security.HtmlEncode(ProductName);
                    }
                    else
                    {
                        SEKeywords = DB.RSFieldByLocale(rs, "SEKeywords", ThisCustomer.LocaleSetting);
                    }
                    SENoScript = DB.RSFieldByLocale(rs, "SENoScript", ThisCustomer.LocaleSetting);
                }
            }

            //Log all views of unknown and registered customer
            if (!AppLogic.ProductIsMLExpress() && (AppLogic.AppConfigBool("DynamicRelatedProducts.Enabled") || AppLogic.AppConfigBool("RecentlyViewedProducts.Enabled")))
            {
                ThisCustomer.LogProductView(ProductID);
            }

            if (IsAKit && !Vortx.MobileFramework.MobileHelper.isMobile())
            {
                Server.Transfer(ResolveClientUrl("~/kitproduct.aspx"), true);
                return;
            }
            else if (IsAKit && Vortx.MobileFramework.MobileHelper.isMobile())
            {
                Server.Transfer(ResolveClientUrl("~/mobilekitproduct.aspx"), true);
                return;
            }

            CategoryName     = CategoryHelper.GetEntityName(CategoryID, ThisCustomer.LocaleSetting);
            SectionName      = SectionHelper.GetEntityName(SectionID, ThisCustomer.LocaleSetting);
            ManufacturerName = ManufacturerHelper.GetEntityName(ManufacturerID, ThisCustomer.LocaleSetting);
            DistributorName  = DistributorHelper.GetEntityName(DistributorID, ThisCustomer.LocaleSetting);
            GenreName        = GenreHelper.GetEntityName(GenreID, ThisCustomer.LocaleSetting);
            VectorName       = VectorHelper.GetEntityName(VectorID, ThisCustomer.LocaleSetting);

            String SourceEntityInstanceName = String.Empty;

            if (ManufacturerID != 0)
            {
                Profile.LastViewedEntityName         = EntityDefinitions.readonly_ManufacturerEntitySpecs.m_EntityName;
                Profile.LastViewedEntityInstanceID   = ManufacturerID.ToString();
                Profile.LastViewedEntityInstanceName = ManufacturerName;

                String NewURL = AppLogic.GetStoreHTTPLocation(false, false) + SE.MakeProductLink(ProductID, ActualSEName);
                HttpContext.Current.Response.Write("<html><head><title>Object Moved</title></head><body><b>Object moved to <a href=\"" + NewURL + "\">HERE</a></b></body></html>");
                Response.Status = "301 Moved Permanently";
                Response.AddHeader("Location", NewURL);
                HttpContext.Current.Response.End();
            }
            else if (DistributorID != 0)
            {
                Profile.LastViewedEntityName         = EntityDefinitions.readonly_DistributorEntitySpecs.m_EntityName;
                Profile.LastViewedEntityInstanceID   = DistributorID.ToString();
                Profile.LastViewedEntityInstanceName = DistributorName;

                String NewURL = AppLogic.GetStoreHTTPLocation(false, false) + SE.MakeProductLink(ProductID, ActualSEName);
                HttpContext.Current.Response.Write("<html><head><title>Object Moved</title></head><body><b>Object moved to <a href=\"" + NewURL + "\">HERE</a></b></body></html>");
                Response.Status = "301 Moved Permanently";
                Response.AddHeader("Location", NewURL);
                HttpContext.Current.Response.End();
            }
            else if (GenreID != 0)
            {
                Profile.LastViewedEntityName         = EntityDefinitions.readonly_GenreEntitySpecs.m_EntityName;
                Profile.LastViewedEntityInstanceID   = GenreID.ToString();
                Profile.LastViewedEntityInstanceName = GenreName;

                String NewURL = AppLogic.GetStoreHTTPLocation(false, false) + SE.MakeProductLink(ProductID, ActualSEName);
                HttpContext.Current.Response.Write("<html><head><title>Object Moved</title></head><body><b>Object moved to <a href=\"" + NewURL + "\">HERE</a></b></body></html>");
                Response.Status = "301 Moved Permanently";
                Response.AddHeader("Location", NewURL);
                HttpContext.Current.Response.End();
            }
            else if (VectorID != 0)
            {
                Profile.LastViewedEntityName         = EntityDefinitions.readonly_VectorEntitySpecs.m_EntityName;
                Profile.LastViewedEntityInstanceID   = VectorID.ToString();
                Profile.LastViewedEntityInstanceName = VectorName;

                String NewURL = AppLogic.GetStoreHTTPLocation(false, false) + SE.MakeProductLink(ProductID, ActualSEName);
                HttpContext.Current.Response.Write("<html><head><title>Object Moved</title></head><body><b>Object moved to <a href=\"" + NewURL + "\">HERE</a></b></body></html>");
                Response.Status = "301 Moved Permanently";
                Response.AddHeader("Location", NewURL);
                HttpContext.Current.Response.End();
            }
            else if (CategoryID != 0)
            {
                Profile.LastViewedEntityName         = EntityDefinitions.readonly_CategoryEntitySpecs.m_EntityName;
                Profile.LastViewedEntityInstanceID   = CategoryID.ToString();
                Profile.LastViewedEntityInstanceName = CategoryName;

                String NewURL = AppLogic.GetStoreHTTPLocation(false, false) + SE.MakeProductLink(ProductID, ActualSEName);
                HttpContext.Current.Response.Write("<html><head><title>Object Moved</title></head><body><b>Object moved to <a href=\"" + NewURL + "\">HERE</a></b></body></html>");
                Response.Status = "301 Moved Permanently";
                Response.AddHeader("Location", NewURL);
                HttpContext.Current.Response.End();
            }
            else if (SectionID != 0)
            {
                Profile.LastViewedEntityName         = EntityDefinitions.readonly_SectionEntitySpecs.m_EntityName;
                Profile.LastViewedEntityInstanceID   = SectionID.ToString();
                Profile.LastViewedEntityInstanceName = SectionName;

                String NewURL = AppLogic.GetStoreHTTPLocation(false, false) + SE.MakeProductLink(ProductID, ActualSEName);
                HttpContext.Current.Response.Write("<html><head><title>Object Moved</title></head><body><b>Object moved to <a href=\"" + NewURL + "\">HERE</a></b></body></html>");
                Response.Status = "301 Moved Permanently";
                Response.AddHeader("Location", NewURL);
                HttpContext.Current.Response.End();
            }

            SourceEntity             = Profile.LastViewedEntityName;
            SourceEntityInstanceName = Profile.LastViewedEntityInstanceName;
            SourceEntityID           = int.Parse(CommonLogic.IIF(CommonLogic.IsInteger(Profile.LastViewedEntityInstanceID), Profile.LastViewedEntityInstanceID, "0"));

            // validate that source entity id is actually valid for this product:
            if (SourceEntityID != 0)
            {
                String sqlx = string.Format("select count(*) as N from productentity a with (nolock) inner join (select distinct a.entityid, a.EntityType from productentity a with (nolock) left join EntityStore b with (nolock) " +
                                            "on a.EntityID = b.EntityID where ({0} = 0 or StoreID = {1})) b on a.EntityID = b.EntityID and a.EntityType=b.EntityType where ProductID = {2} and a.EntityID = {3} and a.EntityType = {4}"
                                            , CommonLogic.IIF(AppLogic.GlobalConfigBool("AllowEntityFiltering") == true, 1, 0), AppLogic.StoreID(), ProductID, SourceEntityID, DB.SQuote(SourceEntity));
                if (DB.GetSqlN(sqlx) == 0)
                {
                    SourceEntityID = 0;
                }
            }

            // we had no entity context coming in, try to find a category context for this product, so they have some context if possible:
            if (SourceEntityID == 0)
            {
                SourceEntityID = EntityHelper.GetProductsFirstEntity(ProductID, EntityDefinitions.readonly_CategoryEntitySpecs.m_EntityName);
                if (SourceEntityID > 0)
                {
                    CategoryID   = SourceEntityID;
                    CategoryName = CategoryHelper.GetEntityName(CategoryID, ThisCustomer.LocaleSetting);

                    Profile.LastViewedEntityName         = EntityDefinitions.readonly_CategoryEntitySpecs.m_EntityName;
                    Profile.LastViewedEntityInstanceID   = CategoryID.ToString();
                    Profile.LastViewedEntityInstanceName = CategoryName;

                    SourceEntity             = EntityDefinitions.readonly_CategoryEntitySpecs.m_EntityName;
                    SourceEntityInstanceName = CategoryName;
                }
            }

            // we had no entity context coming in, try to find a section context for this product, so they have some context if possible:
            if (SourceEntityID == 0)
            {
                SourceEntityID = EntityHelper.GetProductsFirstEntity(ProductID, EntityDefinitions.readonly_SectionEntitySpecs.m_EntityName);
                if (SourceEntityID > 0)
                {
                    SectionID   = SourceEntityID;
                    SectionName = CategoryHelper.GetEntityName(SectionID, ThisCustomer.LocaleSetting);

                    Profile.LastViewedEntityName         = EntityDefinitions.readonly_SectionEntitySpecs.m_EntityName;
                    Profile.LastViewedEntityInstanceID   = SectionID.ToString();
                    Profile.LastViewedEntityInstanceName = SectionName;

                    SourceEntity             = EntityDefinitions.readonly_SectionEntitySpecs.m_EntityName;
                    SourceEntityInstanceName = SectionName;
                }
            }

            // we had no entity context coming in, try to find a Manufacturer context for this product, so they have some context if possible:
            if (SourceEntityID == 0)
            {
                SourceEntityID = EntityHelper.GetProductsFirstEntity(ProductID, EntityDefinitions.readonly_ManufacturerEntitySpecs.m_EntityName);
                if (SourceEntityID > 0)
                {
                    ManufacturerID   = SourceEntityID;
                    ManufacturerName = CategoryHelper.GetEntityName(ManufacturerID, ThisCustomer.LocaleSetting);

                    Profile.LastViewedEntityName         = EntityDefinitions.readonly_ManufacturerEntitySpecs.m_EntityName;
                    Profile.LastViewedEntityInstanceID   = ManufacturerID.ToString();
                    Profile.LastViewedEntityInstanceName = ManufacturerName;

                    SourceEntity             = EntityDefinitions.readonly_ManufacturerEntitySpecs.m_EntityName;
                    SourceEntityInstanceName = ManufacturerName;
                }
            }

            // build up breadcrumb if we need:
            SectionTitle = Breadcrumb.GetProductBreadcrumb(ProductID, ProductName, SourceEntity, SourceEntityID, ThisCustomer);
            //Reset LastViewedEntityInstanceID to zero if no entities are mapped to the product so the left nav will render properly.
            if (SourceEntityID <= 0)
            {
                HttpContext.Current.Profile.SetPropertyValue("LastViewedEntityInstanceID", "0");
            }

            if (RequiresReg && !ThisCustomer.IsRegistered)
            {
                m_PageOutput += "<br/><br/><br/><br/><b>" + AppLogic.GetString("showproduct.aspx.1", SkinID, ThisCustomer.LocaleSetting) + "</b><br/><br/><br/><a href=\"signin.aspx?returnurl=" + CommonLogic.GetThisPageName(false) + "?ProductID=" + ProductID.ToString() + CommonLogic.IIF(CommonLogic.ServerVariables("QUERY_STRING").Trim().Length > 0, "&" + Security.HtmlEncode(Security.UrlEncode(CommonLogic.ServerVariables("QUERY_STRING"))), String.Empty) + "\">" + AppLogic.GetString("showproduct.aspx.2", SkinID, ThisCustomer.LocaleSetting) + "</a> " + AppLogic.GetString("showproduct.aspx.3", SkinID, ThisCustomer.LocaleSetting);
            }
            else
            {
                AppLogic.eventHandler("ViewProductPage").CallEvent("&ViewProductPage=true");

                // check if the postback was caused by an addtocart button
                if (this.IsPostBack && this.IsAddToCartPostBack)
                {
                    HandleAddToCart();
                    return;
                }

                DB.ExecuteSQL("update product set Looks=Looks+1 where ProductID=" + ProductID.ToString());

                m_PageOutput = "<!-- XmlPackage: " + m_XmlPackage + " -->\n";
                if (m_XmlPackage.Length == 0)
                {
                    m_PageOutput += "<p><b><font color=red>XmlPackage format was chosen, but no XmlPackage was specified!</font></b></p>";
                }
                else
                {
                    using (XmlPackage2 p = new XmlPackage2(m_XmlPackage, ThisCustomer, SkinID, "", "EntityName=" + SourceEntity + "&EntityID=" + SourceEntityID.ToString() + CommonLogic.IIF(CommonLogic.ServerVariables("QUERY_STRING").IndexOf("cartrecid") != -1, "&cartrecid=" + CommonLogic.QueryStringUSInt("cartrecid").ToString(), "&showproduct=1"), String.Empty, true))
                    {
                        m_PageOutput += AppLogic.RunXmlPackage(p, base.GetParser, ThisCustomer, SkinID, true, true);
                        if (p.SectionTitle != "")
                        {
                            SectionTitle = p.SectionTitle;
                        }
                        if (p.SETitle != "")
                        {
                            SETitle = p.SETitle;
                        }
                        if (p.SEDescription != "")
                        {
                            SEDescription = p.SEDescription;
                        }
                        if (p.SEKeywords != "")
                        {
                            SEKeywords = p.SEKeywords;
                        }
                        if (p.SENoScript != "")
                        {
                            SENoScript = p.SENoScript;
                        }
                    }
                }
            }
            litOutput.Text = m_PageOutput;
        }
 public virtual CustomCart DeleteCustomCart(CustomCart entity)
 {
     this.DeleteCustomCart(entity.CustomCartRecId);
     return(entity);
 }
        public virtual CustomCart InsertCustomCart(CustomCart entity)
        {
            CustomCart other = new CustomCart();

            other = entity;
            if (entity.IsTransient())
            {
                string         sql            = @"Insert into CustomCart ( [CustomerID]
				,[PackID]
				,[ShoppingCartRecID]
				,[ProductSKU]
				,[ProductWeight]
				,[ProductID]
				,[VariantID]
				,[Quantity]
				,[ChosenColor]
				,[ChosenColorSKUModifier]
				,[ChosenSize]
				,[ChosenSizeSKUModifier]
				,[CartType]
				,[OriginalRecurringOrderNumber]
				,[ExtensionData]
				,[CreatedOn] )
				Values
				( @CustomerID
				, @PackID
				, @ShoppingCartRecID
				, @ProductSKU
				, @ProductWeight
				, @ProductID
				, @VariantID
				, @Quantity
				, @ChosenColor
				, @ChosenColorSKUModifier
				, @ChosenSize
				, @ChosenSizeSKUModifier
				, @CartType
				, @OriginalRecurringOrderNumber
				, @ExtensionData
				, @CreatedOn );
				Select scope_identity()"                ;
                SqlParameter[] parameterArray = new SqlParameter[] {
                    new SqlParameter("@CustomCartRecID", entity.CustomCartRecId)
                    , new SqlParameter("@CustomerID", entity.CustomerId)
                    , new SqlParameter("@PackID", entity.PackId)
                    , new SqlParameter("@ShoppingCartRecID", entity.ShoppingCartRecId)
                    , new SqlParameter("@ProductSKU", entity.ProductSku ?? (object)DBNull.Value)
                    , new SqlParameter("@ProductWeight", entity.ProductWeight)
                    , new SqlParameter("@ProductID", entity.ProductId)
                    , new SqlParameter("@VariantID", entity.VariantId)
                    , new SqlParameter("@Quantity", entity.Quantity)
                    , new SqlParameter("@ChosenColor", entity.ChosenColor ?? (object)DBNull.Value)
                    , new SqlParameter("@ChosenColorSKUModifier", entity.ChosenColorSkuModifier ?? (object)DBNull.Value)
                    , new SqlParameter("@ChosenSize", entity.ChosenSize ?? (object)DBNull.Value)
                    , new SqlParameter("@ChosenSizeSKUModifier", entity.ChosenSizeSkuModifier ?? (object)DBNull.Value)
                    , new SqlParameter("@CartType", entity.CartType)
                    , new SqlParameter("@OriginalRecurringOrderNumber", entity.OriginalRecurringOrderNumber ?? (object)DBNull.Value)
                    , new SqlParameter("@ExtensionData", entity.ExtensionData ?? (object)DBNull.Value)
                    , new SqlParameter("@CreatedOn", entity.CreatedOn)
                };
                var identity = SqlHelper.ExecuteScalar(this.ConnectionString, CommandType.Text, sql, parameterArray);
                if (identity == DBNull.Value)
                {
                    throw new DataException("Identity column was null as a result of the insert operation.");
                }
                return(GetCustomCart(Convert.ToInt32(identity)));
            }
            return(entity);
        }
Пример #14
0
        private void HandleAddToPack()
        {
            ThisCustomer.RequireCustomerRecord();

            int PackID     = CommonLogic.QueryStringUSInt("PackID");
            int ProductID  = CommonLogic.QueryStringUSInt("ProductID");
            int VariantID  = CommonLogic.QueryStringUSInt("VariantID");
            int CategoryID = CommonLogic.QueryStringUSInt("CategoryID");
            int SectionID  = CommonLogic.QueryStringUSInt("SectionID");
            int Quantity   = CommonLogic.QueryStringUSInt("Quantity");

            if (Quantity == 0)
            {
                Quantity = 1;
            }

            //If editing a pack is from the shopping cart
            bool FromCart  = (CommonLogic.QueryStringUSInt("CartRecID") > 0);
            int  CartRecID = CommonLogic.QueryStringUSInt("CartRecID");

            String ChosenColor            = String.Empty;
            String ChosenColorSKUModifier = String.Empty;
            String ChosenSize             = String.Empty;
            String ChosenSizeSKUModifier  = String.Empty;

            if (CommonLogic.QueryStringCanBeDangerousContent("Color").Length != 0)
            {
                String[] ColorSel = CommonLogic.QueryStringCanBeDangerousContent("Color").Split(',');
                try
                {
                    ChosenColor = ColorSel[0];
                }
                catch { }
                try
                {
                    ChosenColorSKUModifier = ColorSel[1];
                }
                catch { }
            }
            if (ChosenColor.Length != 0)
            {
                ThisCustomer.ThisCustomerSession["ChosenColor"] = ChosenColor;
            }


            if (CommonLogic.QueryStringCanBeDangerousContent("Size").Length != 0)
            {
                String[] SizeSel = CommonLogic.QueryStringCanBeDangerousContent("Size").Split(',');
                try
                {
                    ChosenSize = SizeSel[0];
                }
                catch { }
                try
                {
                    ChosenSizeSKUModifier = SizeSel[1];
                }
                catch { }
            }
            if (ChosenSize.Length != 0)
            {
                ThisCustomer.ThisCustomerSession["ChosenSize"] = ChosenSize;
            }

            if (Quantity > 0)
            {
                // add to custom cart:
                if (FromCart)
                {
                    CustomCart.AddItem(PackID, ProductID, VariantID, Quantity, ChosenColor, ChosenColorSKUModifier, ChosenSize, ChosenSizeSKUModifier, CartRecID, ThisCustomer, CartTypeEnum.ShoppingCart);
                }
                else
                {
                    CustomCart cart = new CustomCart(ThisCustomer, PackID, 1, CartTypeEnum.ShoppingCart);
                    cart.AddItem(ProductID, VariantID, Quantity, ChosenColor, ChosenColorSKUModifier, ChosenSize, ChosenSizeSKUModifier);
                }
            }

            if (CommonLogic.QueryStringCanBeDangerousContent("UpdateCartPack") == "")
            {
                String url = SE.MakeProductAndEntityLink(CommonLogic.QueryStringCanBeDangerousContent("entityname"), PackID, CommonLogic.QueryStringUSInt("entityid"), "");
                url = url + CommonLogic.IIF(FromCart, "?cartrecid=" + CartRecID.ToString(), "");

                RedirectMainContainer(url);
            }
            else
            {
                RedirectMainContainer("shoppingcart.aspx");
            }
        }