Beispiel #1
0
 public ActionResult Create(Post model, HttpPostedFileBase ImagenForm)
 {
     if (ImagenForm != null && ImagenForm.ContentLength > 0)
     {
         byte[] imageData = null;
         using (var binaryReader = new BinaryReader(ImagenForm.InputStream))
         {
             imageData = binaryReader.ReadBytes(ImagenForm.ContentLength);
         }
         model.Imagen = imageData;
     }
     try
     {
         if (ModelState.IsValid)
         {
             model.Activo = true;
             _repo.Alta(model);
             return(RedirectToAction("Index"));
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
     return(View(model));
 }