예제 #1
0
 public ActionResult Edit([Bind(Include = "ID,Image,DisplayOrder,Link,Description,CreatedDate,CreatedBy,ModifiedDate,ModifiedBy,Status")] Slide slide)
 {
     if (ModelState.IsValid)
     {
         db.Entry(slide).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(slide));
 }
예제 #2
0
 public ActionResult Edit([Bind(Include = "IdContact,FirstName,LastName,Email,Message")] Contact contact)
 {
     if (ModelState.IsValid)
     {
         db.Entry(contact).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(contact));
 }
예제 #3
0
 public ActionResult Edit(Customer customer)
 {
     if (ModelState.IsValid)
     {
         customer.ModifiedDay     = DateTime.Now;
         db.Entry(customer).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(customer));
 }
예제 #4
0
 public ActionResult Edit([Bind(Include = "CategoryID,ShowOnHome,CategoryName,CreatedDate,CreatedBy,ModifiedDate,ModifiedBy,MetaKeywords")] Category category)
 {
     if (ModelState.IsValid)
     {
         category.ModifiedDate    = DateTime.Now;
         db.Entry(category).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(category));
 }
예제 #5
0
 public ActionResult Edit([Bind(Include = "SupplierID,SupplierName,CreatedDate,CreatedBy,ModifiedDate,ModifiedBy")] Supplier supplier)
 {
     if (ModelState.IsValid)
     {
         supplier.ModifiedDate    = DateTime.Now;
         db.Entry(supplier).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(supplier));
 }
예제 #6
0
 public ActionResult Edit([Bind(Include = "IDProduct,ProductName,MetaTitle,Description,Image,MoreImage1,MoreImage2,MoreImage3,Price,Entryprice,PromotionPrice,IncludedVAT,Quantity,CategoryID,SupplierID,Detail,CreatedDate,CreatedBy,ModifiedDate,ModifiedBy")] Product product, HttpPostedFileBase Image, HttpPostedFileBase MoreImage1, HttpPostedFileBase MoreImage2, HttpPostedFileBase MoreImage3)
 {
     if (ModelState.IsValid)
     {
         if (product.Image != null)
         {
             try
             {
                 var fileName = Path.GetFileName(Image.FileName);
                 product.Image = fileName;
                 var path = Path.Combine(Server.MapPath("~/Images"), fileName);
                 Image.SaveAs(path);
             }
             catch
             {
             }
         }
         if (MoreImage1 != null && MoreImage1.ContentLength > 0)
         {
             try
             {
                 var fileName1 = Path.GetFileName(MoreImage1.FileName);
                 product.MoreImage1 = fileName1;
                 var path1 = Path.Combine(Server.MapPath("~/Images"), fileName1);
                 Image.SaveAs(path1);
             }
             catch
             {
             }
         }
         if (MoreImage2 != null && MoreImage2.ContentLength > 0)
         {
             try
             {
                 var fileName2 = Path.GetFileName(MoreImage2.FileName);
                 product.MoreImage2 = fileName2;
                 var path2 = Path.Combine(Server.MapPath("~/Images"), fileName2);
                 Image.SaveAs(path2);
             }
             catch
             {
             }
         }
         if (MoreImage3 != null && MoreImage3.ContentLength > 0)
         {
             try
             {
                 var fileName3 = Path.GetFileName(MoreImage3.FileName);
                 product.MoreImage3 = fileName3;
                 var path3 = Path.Combine(Server.MapPath("~/Images"), fileName3);
                 Image.SaveAs(path3);
             }
             catch
             {
             }
         }
         product.ModifiedDate    = DateTime.Now;
         db.Entry(product).State = EntityState.Modified;
         if (Image == null)
         {
             db.Entry(product).Property(m => m.Image).IsModified = false;
         }
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.CategoryID = new SelectList(db.Categories, "CategoryID", "CategoryName", product.CategoryID);
     ViewBag.SupplierID = new SelectList(db.Suppliers, "SupplierID", "SupplierName", product.SupplierID);
     return(View(product));
 }