public ActionResult Edit(PictureElement element) { if (ModelState.IsValid) { if(Request.Files.Count > 0) { var file = Request.Files[0]; if(file != null && file.ContentLength > 0) { element.ImageMimeType = file.ContentType; element.ImageData = new byte[file.ContentLength]; file.InputStream.Read(element.ImageData, 0, file.ContentLength); } } picturesRepo.Save(element); TempData["status"] = string.Format("Изображение {0} было сохранено", element.Name); return RedirectToAction("Index"); } else { return View(element); } }
public ViewResult Create() { var element = new PictureElement(); element.Name = " "; element.StartTime = " "; element.Link = " "; return View("Edit", element); }