本文整理汇总了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");
}
示例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");
}
示例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");
}
示例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");
}
示例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");
}
}