public ActionResult DeleteConfirmed(int id) { var TId = db.Thevideos.Find(id).TeacherClass.TeaLevelID; Thevideo thevideo = db.Thevideos.Find(id); db.Thevideos.Remove(thevideo); db.SaveChanges(); return(RedirectToAction("IndexVideo", new { id = TId })); }
public ActionResult Edit([Bind(Include = "VideoId,VideoPath,Date,TeaClassID,NumOfView")] Thevideo thevideo) { if (ModelState.IsValid) { db.Entry(thevideo).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.TeaClassID = new SelectList(db.TeacherClasses, "TeaLevelID", "TeachId", thevideo.TeaClassID); return(View(thevideo)); }
// GET: Thevideos/Delete/5 public ActionResult DeleteVideo(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Thevideo thevideo = db.Thevideos.Find(id); if (thevideo == null) { return(HttpNotFound()); } return(View(thevideo)); }
// GET: Thevideos/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Thevideo thevideo = db.Thevideos.Find(id); if (thevideo == null) { return(HttpNotFound()); } ViewBag.TeaClassID = new SelectList(db.TeacherClasses, "TeaLevelID", "TeachId", thevideo.TeaClassID); return(View(thevideo)); }
public ActionResult CreateVideo(Thevideo thevideo, int id, HttpPostedFileBase upload) { if (ModelState.IsValid) { string[] arr = upload.FileName.Split('.'); string filename = thevideo.VideoId + "." + arr[arr.Length - 1]; string path = Path.Combine(Server.MapPath("~/video"), filename); upload.SaveAs(path); //var u = db.Students.FirstOrDefault(x => x.StuID == student.StuID); thevideo.VideoPath = filename; //string[] arr = path.Split('='); //path = arr[arr.Length - 1]; var Tid = db.TeacherClasses.Find(id).Teacher.TeachId; ViewBag.Tid = Tid; thevideo.TeaClassID = id; db.Thevideos.Add(thevideo); db.SaveChanges(); return(RedirectToAction("TeachLevel", "Admin", new { id = Tid })); } ViewBag.TeaClassID = new SelectList(db.TeacherClasses, "TeaLevelID", "TeachId", thevideo.TeaClassID); return(View(thevideo)); }