// GET: UpdateProduct //Update Price Info public ActionResult UpdatePriceInfo() { ProductPriceUpdateModel productPriceUpdateModel = new ProductPriceUpdateModel(); using (var context = new OnlineShopingEntities()) { productPriceUpdateModel.products = context.Products.ToList(); } return(View(productPriceUpdateModel)); }
public int UpdateProduct(ProductPriceUpdateModel model) { using (var context = new OnlineShopingEntities()) { var product = context.Products.Where(x => x.ProductId == model.ProductId).FirstOrDefault(); if (product != null) { product.Price = model.price; } else { return(-1); } context.SaveChanges(); return(product.ProductId); } }
public ActionResult UpdatePriceInfo(ProductPriceUpdateModel model) { if (ModelState.IsValid) { int id = productUpdateOperation.UpdateProduct(model); if (id > 0) { ModelState.Clear(); ViewBag.Success = "Updated!"; } else { ViewBag.Success = "Failed!"; } } ProductPriceUpdateModel productPriceUpdateModel = new ProductPriceUpdateModel(); using (var context = new OnlineShopingEntities()) { productPriceUpdateModel.products = context.Products.ToList(); } return(View(productPriceUpdateModel)); }