public ActionResult Edit(Product product)
 {
     if (ModelState.IsValid)
     {
         Product products = db.Products.Find(product.Product_ID);
         if (products != null)
         {
             products.Category_ID     = product.Category_ID;
             products.Product_Name    = product.Product_Name;
             products.Quantity        = product.Quantity;
             products.Unit            = product.Unit;
             products.Sale            = product.Sale;
             products.Price           = product.Price;
             products.Discount        = product.Discount;
             products.Final_Price     = product.Final_Price;
             products.Status          = product.Status;
             products.Description     = product.Description;
             products.Date_Modified   = DateTime.Now;
             db.Entry(products).State = EntityState.Modified;
             db.SaveChanges();
             return(RedirectToAction("Index"));
         }
     }
     ViewBag.Category_ID = new SelectList(db.Categories, "Category_ID", "Category1", product.Category_ID);
     return(View(product));
 }
        public ActionResult ChinhSua(SanPham sp, HttpPostedFileBase HinhAnh)
        {
            ViewBag.MaNCC    = new SelectList(db.NhaCungCap.OrderBy(n => n.TenNCC), "MaNCC", "TenNCC", sp.MaNCC);
            ViewBag.MaNSX    = new SelectList(db.NhaSanXuat.OrderBy(n => n.Ten), "MaNSX", "Ten", sp.MaNSX);
            ViewBag.MaLoaiSP = new SelectList(db.LoaiSanPham.OrderBy(n => n.TenLoai), "MaLoaiSP", "TenLoai", sp.MaSP);
            // kiểm tra hình ảnh
            if (HinhAnh.ContentLength > 0)
            {
                // lấy tên hình
                var fileName = Path.GetFileName(HinhAnh.FileName);
                // chuyển hình ảnh vào thư mục images
                var path = Path.Combine(Server.MapPath("~/Content/images"), fileName);
                if (System.IO.File.Exists(path))
                {
                    ViewBag.upload = "Hình ảnh đã tồn tại";
                }
                else
                {
                    HinhAnh.SaveAs(path);
                    sp.HinhAnh         = fileName;
                    db.Entry(sp).State = System.Data.Entity.EntityState.Modified;
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }

            return(View(sp));
        }
Exemple #3
0
 public ActionResult Edit([Bind(Include = "id,id_client,email,numero_telephone,pays,ville,adresse,code_postale")] Coordonnees_de_livraison coordonnees_de_livraison)
 {
     if (ModelState.IsValid)
     {
         db.Entry(coordonnees_de_livraison).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(coordonnees_de_livraison));
 }
 public ActionResult Edit([Bind(Include = "id,nom_produit,id_categorie,prix,image,description,stock,quantite_lots,niveau_reapprovisionnement")] Produit produit)
 {
     if (ModelState.IsValid)
     {
         db.Entry(produit).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(produit));
 }
Exemple #5
0
 public ActionResult Edit([Bind(Include = "id,id_client,id_produit,quantite")] Panier panier)
 {
     if (ModelState.IsValid)
     {
         db.Entry(panier).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(panier));
 }
 public ActionResult Edit([Bind(Include = "Id,Title,Price")] Fruit fruit)
 {
     if (ModelState.IsValid)
     {
         db.Entry(fruit).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(fruit));
 }
Exemple #7
0
 public ActionResult Edit([Bind(Include = "PrdImg_ID,Product_ID,Image,ContentType,Data,Date_Created")] Product_Image product_Image)
 {
     if (ModelState.IsValid)
     {
         db.Entry(product_Image).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.Product_ID = new SelectList(db.Products, "Product_ID", "Product_Name", product_Image.Product_ID);
     return(View(product_Image));
 }
Exemple #8
0
 public ActionResult Edit(Category category)
 {
     if (ModelState.IsValid)
     {
         Category categoryobj = db.Categories.Where(e => e.Category_ID == category.Category_ID).FirstOrDefault();
         if (categoryobj != null)
         {
             categoryobj.Category1       = category.Category1;
             categoryobj.Date_Modified   = DateTime.Now;
             db.Entry(categoryobj).State = EntityState.Modified;
             db.SaveChanges();
             return(RedirectToAction("Index"));
         }
         return(View(category));
     }
     return(View(category));
 }
 public void Update(TEntity entity)
 {
     context.Entry(entity).State = EntityState.Modified;
     context.SaveChanges();
 }