public ActionResult DeleteConfirmed(int id) { SATStudent satstudent = db.SATStudents.Single(s => s.studentId == id); db.SATStudents.DeleteObject(satstudent); db.SaveChanges(); return(RedirectToAction("Index")); }
// // GET: /Student/Edit/5 public ActionResult Edit(int id) { SATStudent satstudent = db.SATStudents.Single(s => s.studentId == id); ViewBag.statusId = new SelectList(db.SATStudentStatuses, "SSID", "SSName", satstudent.statusId); return(View(satstudent)); }
public ActionResult Edit(SATStudent satstudent, HttpPostedFileBase pictureUrl) //must match the name value of the input { if (ModelState.IsValid) { //declare and assign my variable for the imagename //to the default image for no product string imageName = "noImage.jpg"; //code for file upload //check for image if (satstudent.pictureUrl != null) { //get the filename imageName = pictureUrl.FileName; //get the ext string ext = imageName.Substring(imageName.LastIndexOf('.')); //create new filename and add the ext imageName = Guid.NewGuid().ToString() + ext; //save image to webserver pictureUrl.SaveAs(Server.MapPath( "~/Content/images/studentimages/" + imageName)); //end new file stuff //save to the database satstudent.pictureUrl = imageName; } db.SATStudents.AddObject(satstudent); db.ObjectStateManager.ChangeObjectState(satstudent, EntityState.Modified); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.statusId = new SelectList(db.SATStudentStatuses, "SSID", "SSName", satstudent.statusId); return(View(satstudent)); }
// // GET: /Student/Details/5 public ViewResult Details(int id) { SATStudent satstudent = db.SATStudents.Single(s => s.studentId == id); return(View(satstudent)); }
// // GET: /Student/Delete/5 public ActionResult Delete(int id) { SATStudent satstudent = db.SATStudents.Single(s => s.studentId == id); return(View(satstudent)); }