示例#1
0
        // 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));
        }
示例#2
0
        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);
            }
        }
示例#3
0
        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));
        }