コード例 #1
0
 public ActionResult Edit(int id, MedicineViewModel mvm, HttpPostedFileBase ImageFile)
 {
     if (ModelState.IsValid)
     {
         IBL      bl       = new BLImplement();
         Medicine medicine = new Medicine()
         {
             Id                = mvm.Id,
             Name              = mvm.Name,
             GenericName       = mvm.GenericName,
             ActiveIngredients = mvm.ActiveIngredients,
             PortionProperties = mvm.PortionProperties,
             Producer          = mvm.Producer
         };
         try
         {
             if (ImageFile != null)
             {
                 bl.updateMedicinePicture(medicine.Id, ImageFile);
             }
             bl.updateMedicine(medicine);
             ViewBag.Message = String.Format("The Medicine {0} successfully updated", medicine.Name);
             return(RedirectToAction("Index"));
         }
         catch (Exception ex)
         {
             ViewBag.Message = String.Format(ex.Message);
             return(RedirectToAction("Index"));
         }
     }
     return(View(new MedicineViewModel()));
 }