예제 #1
0
        /// <summary>
        /// 关闭浏览器记录学习进度
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult LearningRecord(int id)
        {
            Lession Lession = new Lession();
            Lession = db.Lessions.Find(id);
            if (User.Identity.IsAuthenticated)
            {
                LearningRecord record = db.LearningRecords.Where(sr => sr.UserID == CurrentUser.ID && sr.Lession.CourseID == Lession.CourseID).FirstOrDefault();
                if (record == null)
                {
                    record = new Models.LearningRecord();
                    record.UserID = CurrentUser.ID;
                    record.LessionID = id;
                    record.Time = DateTime.Now;
                    db.LearningRecords.Add(record);
                }
                else
                {
                    record.LessionID = id;
                    record.Time = DateTime.Now;
                }

                db.SaveChanges();
            }
            return Content("");
        }
예제 #2
0
 /// <summary>
 /// 播放课时视屏
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public ActionResult PlayLession(int id)
 {
     Lession lession = new Lession();
     lession = db.Lessions.Find(id);
     return File("/Lessions/" + lession.Path, lession.ContentType);
 }
예제 #3
0
        public ActionResult LessionEdit(Lession model, HttpPostedFileBase file)
        {
            Lession lession = db.Lessions.Find(model.ID);
            string path = "";
            if (file != null)
            {
                path = Server.MapPath(lession.Path);
                System.IO.File.Delete(path);

                string fileName = Path.Combine(Request.MapPath("~/Lessions"), DateHelper.GetTimeStamp() + Path.GetExtension(file.FileName));
                file.SaveAs(fileName);
                path = DateHelper.GetTimeStamp() + Path.GetExtension(file.FileName);
                lession.Path = path;
            }
            lession.Title = model.Title;
            lession.Description = model.Description;
            lession.Remark = model.Remark;
            db.SaveChanges();
            return Redirect("/Admin/CourseShow/" + lession.CourseID);
        }
예제 #4
0
 /// <summary>
 /// 课程显示
 /// </summary>
 /// <returns></returns>
 public ActionResult LessionShow(int id)
 {
     Lession lession = new Lession();
     lession = db.Lessions.Find(id);
     ViewBag.Lession = new vLession(lession);
     return View();
 }
예제 #5
0
 public ActionResult LessionEdit(int id)
 {
     Lession lession = new Lession();
     lession = db.Lessions.Find(id);
     ViewBag.Lession = lession;
     return View();
 }
예제 #6
0
 public ActionResult LessionDelete(int id)
 {
     Lession lession = new Lession();
     lession = db.Lessions.Find(id);
     var path = Server.MapPath("~/Lessions"+lession.Path);
     System.IO.File.Delete(path);
     db.Lessions.Remove(lession);
     db.SaveChanges();
     return Content("ok");
 }
예제 #7
0
        public ActionResult AddLession(Lession model, HttpPostedFileBase file)
        {
            string fileName = Path.Combine(Request.MapPath("~/Lessions"), DateHelper.GetTimeStamp() + Path.GetExtension(file.FileName));
            file.SaveAs(fileName);
            var path = DateHelper.GetTimeStamp() + Path.GetExtension(file.FileName);

            model.Time = DateTime.Now;
            model.ContentType = file.ContentType;
            model.Path = path;
            db.Lessions.Add(model);
            db.SaveChanges();
            return Redirect("/Admin/CourseShow/"+model.CourseID);
        }
예제 #8
0
        public ActionResult AddLession(Lession model, HttpPostedFileBase file)
        {
            var temp = db.Lessions.Where(l => l.CourseID == model.CourseID && l.Title == model.Title).FirstOrDefault();
            if (temp != null)
            {
                return Redirect("/Admin/AdminMessage?msg=该课时已经存在!");
            }

            var radom = DateHelper.GetTimeStamp();
            var course = db.Courses.Find(model.CourseID);
            string root = "~/Lessions/" + course.Title + "/";
            var phicyPath = HostingEnvironment.MapPath(root);

            file.SaveAs(phicyPath + file.FileName);

            var exten = Path.GetExtension(file.FileName);

            if (!exten.Equals(".flv"))
            {
                var video = new VideoFile(phicyPath + file.FileName);
                video.Convert(".flv", Quality.Medium).MoveTo(phicyPath + radom + ".flv");
                model.Path = fileServer + "Lessions/" + course.Title + "/" + radom + ".flv";
                if (System.IO.File.Exists(phicyPath + file.FileName))
                {
                    //如果存在则删除
                    System.IO.File.Delete(phicyPath + file.FileName);
                }
            }
            else
            {
                model.Path = fileServer + "Lessions/" + course.Title + "/" + file.FileName;
            }
            // model.Path = fileServer + "Lessions/" + course.Title + "/" + file.FileName;
            model.Time = DateTime.Now;
            model.ContentType = file.ContentType;
            model.Browses = 0;
            model.Route = 1;

            db.Lessions.Add(model);
            db.SaveChanges();

            return Redirect("/Admin/CourseShow/" + model.CourseID);
        }
예제 #9
0
        public ActionResult LessionEdit(Lession model, HttpPostedFileBase file)
        {
            Lession lession = db.Lessions.Find(model.ID);
            Course course = db.Courses.Find(lession.CourseID);
            string path = "";
            if (file != null)
            {
                var oldPath = Server.MapPath("~/" + lession.Path.Replace(fileServer, ""));
                System.IO.File.Delete(oldPath);

                string root = "~/Lessions/" + course.Title + "/";
                var phicyPath = HostingEnvironment.MapPath(root);
                file.SaveAs(phicyPath + file.FileName);

                path = fileServer + "Lessions/" + course.Title + "/" + file.FileName;
                lession.Path = path;
            }
            lession.Title = model.Title;
            lession.Description = model.Description;
            lession.Remark = model.Remark;
            db.SaveChanges();
            return Redirect("/Admin/CourseShow/" + lession.CourseID);
        }