Пример #1
0
        public ActionResult Add(string Category, string Title, string Lecturer, string Cover, string Description)
        {
            List<Category> categories = bllSession.ICategoryBLL.GetList("").ToList();
            ViewBag.Categories = categories;
            if (!ModelState.IsValid)
            {
                ModelState.AddModelError("", "数据填写错误!");
            }
            else
            {
                Course course = new Course();
                course.Title = Title;
                course.Category = Category;
                course.Lecturer = Lecturer;
                course.Description = Description;
                course.Cover = Cover;
                course.Time = DateTime.Now;
                course.Browses = 0;
                try
                {
                    bllSession.ICourseBLL.Insert(course);
                    return Redirect("/Admin/Course/Index");
                }
                catch
                {
                    log.Error(new LogContent("增加课程出错", LogType.异常.ToString(), HttpHelper.GetIPAddress()));
                    ModelState.AddModelError("", "增加出现异常");
                }

            }
            return View();
        }
Пример #2
0
 public ActionResult Show(int id)
 {
     Course course = new Course();
     course = bllSession.ICourseBLL.GetEntityWithRefence(id);
     course.Browses = course.Browses + 1;
     bllSession.ICourseBLL.Update(course);
     return View(course);
 }
Пример #3
0
 public ActionResult Add(int CourseId)
 {
     List<Category> categories = bllSession.ICategoryBLL.GetList("").ToList();
     ViewBag.Categories = categories;
     Course course = new Course();
     course = bllSession.ICourseBLL.GetEntity(CourseId);
     ViewBag.Course = course;
     return View();
 }
Пример #4
0
 public ActionResult Add(HttpPostedFileBase file, Video model)
 {
     List<Category> categories = bllSession.ICategoryBLL.GetList("").ToList();
     ViewBag.Categories = categories;
     Course course = new Course();
     course = bllSession.ICourseBLL.GetEntity(model.CourseId);
     ViewBag.Course = course;
     if (file != null)
     {
         try
         {
             string random = DateHelper.GetTimeStamp();
             string root = "~/Videos/" + model.CourseId + "/";
             var phicyPath = HostingEnvironment.MapPath(root);
             Directory.CreateDirectory(phicyPath);
             file.SaveAs(phicyPath + random + Path.GetExtension(file.FileName));
             model.Path = "/Videos/" + model.CourseId + "/" + random + Path.GetExtension(file.FileName);
             model.UserId = CurrentUser.Id;
             model.Time = DateTime.Now;
             model.Browses = 0;
             model.ContentType = file.ContentType;
             bllSession.IVideoBLL.Insert(model);
             log.Info(new LogContent(CurrentUser.Username + "增加了视屏", LogType.记录.ToString(), HttpHelper.GetIPAddress()));
             return Redirect("/Admin/Course/Show/" + model.CourseId);
         }
         catch
         {
             log.Error(new LogContent("增加视屏出错", LogType.异常.ToString(), HttpHelper.GetIPAddress()));
             ModelState.AddModelError("", "增加视屏出错!");
         }
     }
     else
     {
         model.UserId = CurrentUser.Id;
         model.Time = DateTime.Now;
         model.Browses = 0;
         bllSession.IVideoBLL.Insert(model);
         log.Info(new LogContent(CurrentUser.Username+"增加了网盘链接视屏", LogType.记录.ToString(), HttpHelper.GetIPAddress()));
         return Redirect("/Admin/Course/Show/" + model.CourseId);
     }
     return View();
 }
Пример #5
0
 public Video()
 {
     User = new User();
     Course = new Course();
 }
Пример #6
0
 public ActionResult Show(int id)
 {
     Course course = new Course();
     course = bllSession.ICourseBLL.GetEntity(id);
     List<Video> videos = new List<Video>();
     videos = bllSession.IVideoBLL.GetList("CourseId="+id).ToList();
     ViewBag.Videos = videos;
     return View(course);
 }
Пример #7
0
 public ActionResult Edit(string Category, string Title, string Lecturer, string Cover, string Description,int Id)
 {
     List<Category> categories = bllSession.ICategoryBLL.GetList("").ToList();
     ViewBag.Categories = categories;
     ///获取课程
     Course course = new Course();
     if (!ModelState.IsValid)
     {
         ModelState.AddModelError("", "数据填写错误!");
     }
     else
     {
         course.Title = Title;
         course.Category = Category;
         course.Lecturer = Lecturer;
         course.Description = Description;
         course.Cover = Cover;
         course.Id = Id;
         try
         {
             bllSession.ICourseBLL.Update(course);
             return Redirect("/Admin/Course/Index");
         }
         catch
         {
             log.Error(new LogContent("修改课程出错", LogType.异常.ToString(), HttpHelper.GetIPAddress()));
             ModelState.AddModelError("", "修改出现异常");
         }
     }
     return View(course);
 }