当前位置: 首页>>代码示例>>C#>>正文


C# FormCollection.ProcessPostData方法代码示例

本文整理汇总了C#中System.Web.Mvc.FormCollection.ProcessPostData方法的典型用法代码示例。如果您正苦于以下问题:C# FormCollection.ProcessPostData方法的具体用法?C# FormCollection.ProcessPostData怎么用?C# FormCollection.ProcessPostData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Web.Mvc.FormCollection的用法示例。


在下文中一共展示了FormCollection.ProcessPostData方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Prices

        public ActionResult Prices(FormCollection form)
        {
            using (var context = new ShopContainer())
            {
                var products = context.Product.Include("Brand").Include("Category").ToList();

                PostCheckboxesData cbDataNew = form.ProcessPostCheckboxesData("new");
                PostCheckboxesData cbDataSpec = form.ProcessPostCheckboxesData("special");
                PostCheckboxesData cbDataPublish = form.ProcessPostCheckboxesData("publish");
                PostData oldPriceData = form.ProcessPostData("oldprice");
                PostData priceData = form.ProcessPostData("price");

                foreach (var kvp in cbDataNew)
                {
                    var productId = kvp.Key;
                    bool productValue = kvp.Value;

                    products.First(p => p.Id == productId).IsNew = productValue;
                }

                foreach (var kvp in cbDataSpec)
                {
                    var productId = kvp.Key;
                    bool productValue = kvp.Value;

                    products.First(p => p.Id == productId).IsSpecialOffer = productValue;
                }

                foreach (var kvp in cbDataPublish)
                {
                    var productId = kvp.Key;
                    bool productValue = kvp.Value;

                    products.First(p => p.Id == productId).Published = productValue;
                }

                foreach (var kvp in oldPriceData)
                {
                    int productId = Convert.ToInt32(kvp.Key);
                    foreach (var value in kvp.Value)
                    {
                        var productValue = Convert.ToDecimal(value.Value);
                        products.First(p => p.Id == productId).OldPrice = productValue;
                    }
                }

                foreach (var kvp in priceData)
                {
                    int productId = Convert.ToInt32(kvp.Key);
                    foreach (var value in kvp.Value)
                    {
                        var productValue = Convert.ToDecimal(value.Value);
                        products.First(p => p.Id == productId).Price = productValue;
                    }
                }

                context.SaveChanges();
            }
            return RedirectToAction("Prices");
        }
开发者ID:fathurxzz,项目名称:aleqx,代码行数:60,代码来源:ProductController.cs

示例2: Recalculate

        public ActionResult Recalculate(FormCollection form)
        {
            var post = form.ProcessPostData("q");

            foreach (var kvp in post)
            {
                int orderItemId = Convert.ToInt32(kvp.Key);
                foreach (var q in kvp.Value)
                {
                    int orderItemQuantity = Convert.ToInt32(q.Value);

                    foreach (var orderItem in WebSession.OrderItems.Select(oi => oi.Value))
                    {
                        if (orderItem.GetHashCode() == orderItemId)
                        {
                            orderItem.Quantity = orderItemQuantity;
                        }
                    }
                }
            }

            return RedirectToAction("Index");
        }
开发者ID:fathurxzz,项目名称:aleqx,代码行数:23,代码来源:CartController.cs

示例3: Attributes

        public ActionResult Attributes(int productId, FormCollection form, string page)
        {
            _repository.LangId = CurrentLangId;
            var product = _repository.GetProduct(productId);
            PostCheckboxesData attrData = form.ProcessPostCheckboxesData("attr", "productId");
            PostData staticAttrData = form.ProcessPostData("tb", "productId");

            product.ProductAttributeValues.Clear();
            string searchCriteriaAttributes = "";

            foreach (var kvp in attrData)
            {
                var attributeValueId = kvp.Key;
                bool attributeValue = kvp.Value;

                if (attributeValue)
                {
                    var productAttributeValue = _repository.GetProductAttributeValue(attributeValueId);
                    searchCriteriaAttributes += productAttributeValue.ProductAttributeId + "-" + attributeValueId + ";";
                    product.ProductAttributeValues.Add(productAttributeValue);
                }
            }

            foreach (var kvp in staticAttrData)
            {
                int attributeId = Convert.ToInt32(kvp.Key);
                foreach (var value in kvp.Value)
                {
                    string attributeValue = value.Value;

                    var productAttribute = _repository.GetProductAttribute(attributeId);

                    //productAttribute.ProductAttributeStaticValues.Clear();

                    ProductAttributeStaticValue productAttributeValue = null;
                    productAttributeValue = _repository.GetProductAttributeStaticValue(productAttribute.Id, product.Id);


                    if (string.IsNullOrEmpty(attributeValue))
                    {
                        if (productAttributeValue != null)
                            _repository.DeleteProductAttributeStaticValue(productAttributeValue.Id);
                    }
                    else
                    {
                        if (productAttributeValue == null)
                        {
                            productAttributeValue = new ProductAttributeStaticValue
                            {
                                Title = attributeValue,
                                ProductAttribute = productAttribute,
                                ProductId = product.Id
                            };
                            _repository.AddProductAttributeStaticValue(productAttributeValue);
                        }
                        else
                        {
                            productAttributeValue.Title = attributeValue;
                            _repository.SaveProductAttributeStaticValue(productAttributeValue);
                        }
                    }
                }
            }

            product.SearchCriteriaAttributes = searchCriteriaAttributes;

            _repository.SaveProduct(product);

            return !string.IsNullOrEmpty(page) ? RedirectToAction("Index", new { page = page }) : RedirectToAction("Index");
        }
开发者ID:fathurxzz,项目名称:aleqx,代码行数:70,代码来源:ProductController.cs

示例4: SaveSubscribersSettings

        public ActionResult SaveSubscribersSettings(FormCollection form)
        {
            using (var context = new ContentStorage())
            {
                PostData agentsData = form.ProcessPostData("agent");
                PostData touristData = form.ProcessPostData("tourist");

                int[] agentIds =
                    agentsData.Where(d => bool.Parse(d.Value["agent"])).Select(id => Convert.ToInt32(id.Key)).ToArray();
                int[] touristIds =
                    touristData.Where(d => bool.Parse(d.Value["tourist"])).Select(id => Convert.ToInt32(id.Key)).ToArray
                        ();

                var customers = context.Customers.ToList();
                var agents =
                    (from customer in customers from id in agentIds where customer.Id == id select customer).ToList();
                var tourists =
                    (from customer in customers from id in touristIds where customer.Id == id select customer).ToList();
                IEnumerable<Customers> all = agents.Concat(tourists);


                foreach (var customer in customers)
                {
                    customer.IsActive = 0;
                }

                foreach (var customer in customers)
                {
                    if (agentIds.Contains(Convert.ToInt32(customer.Id)) || touristIds.Contains(Convert.ToInt32(customer.Id)))
                        customer.IsActive = 1;
                }
                context.SaveChanges();
            }
            return RedirectToAction("SubscribersList");
        }
开发者ID:fathurxzz,项目名称:aleqx,代码行数:35,代码来源:SubscribeController.cs

示例5: Attributes

        public ActionResult Attributes(int productId, FormCollection form)
        {
            using (var context = new ShopContainer())
            {
                var product = context.Product.Include("ProductAttributeValues").First(p => p.Id == productId);

                PostCheckboxesData cbData = form.ProcessPostCheckboxesData("attr", "productId");
                PostData staticAttrData = form.ProcessPostData("tb", "productId");

                product.ProductAttributeValues.Clear();

                foreach (var kvp in cbData)
                {
                    var attributeValueId = kvp.Key;
                    bool attributeValue = kvp.Value;

                    if (attributeValue)
                    {
                        var productAttributeValue = context.ProductAttributeValues.First(pv => pv.Id == attributeValueId);
                        product.ProductAttributeValues.Add(productAttributeValue);
                    }
                }


                foreach (var kvp in staticAttrData)
                {
                    int attributeId = Convert.ToInt32(kvp.Key);
                    foreach (var value in kvp.Value)
                    {
                        string attributeValue = value.Value;

                        var productAttribute = context.ProductAttribute.Include("ProductAttributeStaticValues").First(pa => pa.Id == attributeId);

                        //productAttribute.ProductAttributeStaticValues.Clear();

                        ProductAttributeStaticValues productAttributeValue = null;
                        productAttributeValue = context.ProductAttributeStaticValues.FirstOrDefault(
                                pav => pav.ProductAttribute.Id == productAttribute.Id && pav.Product.Id == product.Id);


                        if (string.IsNullOrEmpty(attributeValue))
                        {
                            if (productAttributeValue != null)
                                context.DeleteObject(productAttributeValue);
                        }
                        else
                        {
                            if (productAttributeValue == null)
                            {



                                productAttributeValue = new ProductAttributeStaticValues
                                                            {
                                                                Value = attributeValue,
                                                                ProductAttribute = productAttribute
                                                            };
                                product.ProductAttributeStaticValues.Add(productAttributeValue);

                            }
                            else
                            {
                                productAttributeValue.Value = attributeValue;
                            }
                        }
                        //productAttribute.ProductAttributeValues.Add(productAttributeValue);


                    }
                }

                context.SaveChanges();




                return RedirectToAction("Index");
            }
        }
开发者ID:fathurxzz,项目名称:aleqx,代码行数:79,代码来源:ProductController.cs


注:本文中的System.Web.Mvc.FormCollection.ProcessPostData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。