コード例 #1
0
 public ActionResult Edit(int id, FormCollection collection, HttpPostedFileBase Parvandeh)
 {
     try
     {
         if (Parvandeh == null)
         {
             dc.Product_Edit(id, collection["Name"], null, collection["Abstract"], collection["Description"], Convert.ToInt32(collection["SubGroup"]));
         }
         else
         {
             var _Bytes = new byte[Parvandeh.ContentLength];
             Parvandeh.InputStream.Read(_Bytes, 0, Parvandeh.ContentLength);
             dc.Product_Edit(id, collection["Name"], _Bytes, collection["Abstract"], collection["Description"], Convert.ToInt32(collection["SubGroup"]));
         }
         return(RedirectToAction("Index"));
     }
     catch
     {
         var product = dc.Products.Where(x => x.Id == id).FirstOrDefault();
         if (Request.IsAjaxRequest())
         {
             return(PartialView(product));
         }
         return(View(product));
     }
 }