Ejemplo n.º 1
0
 public ActionResult Edit(Product product, IFormFile Image, string action)
 {
     if (ModelState.IsValid)
     {
         if (Image != null)
         {
             using (var binaryReader = new BinaryReader(Image.OpenReadStream()))
             {
                 product.ImageData     = binaryReader.ReadBytes((int)Image.Length);
                 product.ImageMimeType = Image.ContentType;
             }
         }
         db.SaveProduct(product);
         TempData["message"] = string.Format("Изменения \"{0}\" были сохранены", product.Name);
         if (action == "SaveAndNextProduct")
         {
             return(RedirectToAction("Edit", new { id = db.FindNextId(product.Id) }));
         }
         return(RedirectToAction("IndexProduct"));
     }
     else
     {
         // Что-то не так со значениями данных
         return(View(product));
     }
 }