本文整理汇总了C#中ProductRepository.Update方法的典型用法代码示例。如果您正苦于以下问题:C# ProductRepository.Update方法的具体用法?C# ProductRepository.Update怎么用?C# ProductRepository.Update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ProductRepository
的用法示例。
在下文中一共展示了ProductRepository.Update方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Update
public ActionResult Update(Product produto )
{
ProductRepository<Product> dao = new ProductRepository<Product>();
dao.Update(produto);
return RedirectToAction("index", "Product");
}
示例2: Put
// PUT api/products/5
public IEnumerable<Product> Put(int id, [FromBody]Product value)
{
ProductRepository repo = new ProductRepository();
value.ProductId = id;
repo.Update(value);
return repo.Retrieve();
}
示例3: Edit
public ActionResult Edit(Product product)
{
if (ModelState.IsValid)
{
ProductRepository p = new ProductRepository(_sqlConnectionString);
p.Update(product);
return RedirectToAction("Index");
}
return View(product);
}
示例4: ShouldUpdateAProduct
public void ShouldUpdateAProduct()
{
var productRepository = new ProductRepository(@"Repository\Products.txt", "Product");
productRepository.Update(2,new Product
{
Category = "Fruits",
Name = "Appel",
Price = 12,
Stock = 3
});
var products = productRepository.GetAll().ToArray();
Assert.AreEqual("Appel",products[1].Name);
}
示例5: RepositoryUpdateTest
public void RepositoryUpdateTest()
{
Program.ClearInformation();
IRepository<Product> _productRepository = new ProductRepository();
Product product = new Product(1, "House", "MOPRa,1", "for sale");
_productRepository.Add(product);
product.status = "saled";
_productRepository.Update(product);
Product actual = _productRepository.GetItem(product.id);
Product expected = new Product(1, "House", "MOPRa,1", "saled");
Assert.AreEqual(actual.id, product.id);
Assert.AreEqual(actual.name, product.name);
Assert.AreEqual(actual.status, product.status);
Assert.AreEqual(actual.address, product.address);
Program.ClearInformation();
}
示例6: Buy
public ActionResult Buy(Product product)
{
IRepository<Product> _productRepository = new ProductRepository();
Product buyingProduct = _productRepository.GetItem(product.id);
if (buyingProduct.status == "saled")
{
return RedirectToAction("ErrorOfSaledProduct");
}
else
{
buyingProduct.status = "saled";
_productRepository.Update(buyingProduct);
return RedirectToAction("Shop");
}
}