예제 #1
0
 public ActionResult Edit(Thing thing)
 {
     if (ModelState.IsValid)
     {
         repository.SaveThing(thing);
         TempData["message"] = string.Format("Изменение информации о вещи \"{0}\" сохранены", thing.Name);
         return(RedirectToAction("Index"));
     }
     else
     {
         return(View(thing));
     }
 }
예제 #2
0
        public ActionResult Edit(Thing thing, HttpPostedFileBase image = null)
        {
            if (ModelState.IsValid)
            {
                if (image != null)
                {
                    thing.ImageMimeType = image.ContentType;
                    thing.ImageData     = new byte[image.ContentLength];
                    image.InputStream.Read(thing.ImageData, 0, image.ContentLength);
                }


                repository.SaveThing(thing);
                TempData["message"] = string.Format("Changing \"{0}\" was saved", thing.Name);
                return(RedirectToAction("Index"));
            }
            else
            {
                return(View(thing));
            }
        }