public ActionResult Edit(Commandant commandant, HttpPostedFileBase ImageFile) { if (Session["userName"] != null) { if (ImageFile != null) { using (var ms = new MemoryStream()) { ImageFile.InputStream.CopyTo(ms); commandant.Image = ms.ToArray(); } if (ModelState.IsValid) { db.Entry(commandant).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } } else { if (ModelState.IsValid) { db.Entry(commandant).State = EntityState.Modified; db.Entry(commandant).Property(x => x.Image).IsModified = false; db.SaveChanges(); return(RedirectToAction("Index")); } } return(View(commandant)); } else { return(RedirectToAction("Logout", "Admin")); } }
public ActionResult Edit(Synopsis synopsis, HttpPostedFileBase fileUpload) { if (Session["userName"] != null) { if (fileUpload != null) { using (var ms = new MemoryStream()) { fileUpload.InputStream.CopyTo(ms); synopsis.File = ms.ToArray(); } if (ModelState.IsValid) { db.Entry(synopsis).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } } return(View(synopsis)); } else { return(RedirectToAction("Logout", "Admin")); } }
public ActionResult Edit([Bind(Include = "ID,cyberAlertText,cyberAlertDate,expiresAt")] cyberAlert cyberAlert) { if (Session["userName"] != null) { if (ModelState.IsValid) { db.Entry(cyberAlert).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(cyberAlert)); } else { return(RedirectToAction("Logout", "Admin")); } }
public ActionResult Edit([Bind(Include = "ID,lectureTopic,speakerName,location,date")] Lecture lecture) { if (Session["userName"] != null) { if (ModelState.IsValid) { db.Entry(lecture).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(lecture)); } else { return(RedirectToAction("Logout", "Admin")); } }