public ActionResult AddITrial(ITrial model, HttpPostedFileBase file) { System.IO.Stream stream = file.InputStream; byte[] buffer = new byte[stream.Length]; stream.Read(buffer, 0, (int)stream.Length); stream.Close(); model.Picture = buffer; model.Time = DateTime.Now; db.ITrials.Add(model); db.SaveChanges(); return Redirect("/Admin/ITrialManager"); }
public ActionResult ITrialEdit(ITrial model, HttpPostedFileBase file) { ITrial itrial = db.ITrials.Find(model.ID); itrial.Title = model.Title; itrial.Description = model.Description; itrial.URL = model.URL; itrial.Priority = model.Priority; if (file != null) { System.IO.Stream stream = file.InputStream; byte[] buffer = new byte[stream.Length]; stream.Read(buffer, 0, (int)stream.Length); stream.Close(); itrial.Picture = buffer; } db.SaveChanges(); return Redirect("/Admin/ITrialManager"); }