コード例 #1
0
        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 }));
        }
コード例 #2
0
 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));
 }
コード例 #3
0
        // 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));
        }
コード例 #4
0
        // 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));
        }
コード例 #5
0
        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));
        }