123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.Mvc;
- using EMISOnline.CommonLogic.EducationalServices;
- using Bowin.Web.Controls.Mvc;
- using EMISOnline.ViewModel.Educational;
- using EMISOnline.ViewModel;
- namespace EMISOnline.Web.Controllers.Manage
- {
- public class CourseBuildController : Controller
- {
- //课程建设
- public ICourseBuildServices ICourseBuildServices { get; set; }
- public ActionResult List()
- {
- return View();
- }
- [HttpPost]
- public ActionResult List(int page, int rows, string CourseName, string CourseCode)
- {
- var result = ICourseBuildServices.GetCoursematerList(page, rows, CourseName, CourseCode);
- return Json(result);
- }
- public ActionResult ChapterList(Guid CoursematerialID)
- {
- ViewBag.CoursematerialID = CoursematerialID;
- ViewBag.DefaultVideoTypeID = (int)EMISOnline.ViewModel.EM_OnlineVideoType.Local;
- return View();
- }
- [HttpPost]
- public ActionResult ChapterList(Guid? ParentCourseChapterID, Guid? CourseChapterID, string Name, int? OrderID,
- int VideoTypeID, Guid? CourseVideoID, string OuterVideoUrl,
- Guid CoursematerialID, int type)
- {
- if (type == 1)
- {
- try
- {
- ICourseBuildServices.AddChapter(ParentCourseChapterID, CourseChapterID, Name, OrderID, VideoTypeID,
- CourseVideoID, OuterVideoUrl, CoursematerialID);
- return Json(new ReturnMessage()
- {
- IsSuccess = true,
- Message = "保存成功!"
- });
- }
- catch (Exception ex)
- {
- return Json(new ReturnMessage()
- {
- IsSuccess = false,
- Message = "保存失败:" + ex.Message
- });
- }
- }
- else
- {
- try
- {
- if (ICourseBuildServices.IsAnySubChapter(CourseChapterID.Value))
- {
- return Json(new ReturnMessage()
- {
- IsSuccess = false,
- Message = "删除失败:请先删除子章节!"
- });
- }
- else
- {
- ICourseBuildServices.DeleteChapter(CourseChapterID.Value);
- return Json(new ReturnMessage()
- {
- IsSuccess = true,
- Message = "删除成功!"
- });
- }
- }
- catch (Exception ex)
- {
- return Json(new ReturnMessage()
- {
- IsSuccess = false,
- Message = "删除失败:" + ex.Message
- });
- }
- }
- }
- [HttpPost]
- public ActionResult ChaperVideoList(Guid CourseChapterID)
- {
- var result = ICourseBuildServices.GetChaperVideoList(CourseChapterID);
- return Json(result);
- }
- [HttpPost]
- public ActionResult GetChaperVideo(Guid CourseChapterID)
- {
- var model = new CourseVideoView();
- try
- {
- model = ICourseBuildServices.GetChaperVideoList(CourseChapterID).rows.FirstOrDefault();
- }
- catch { }
- return Json(model);
- }
- public ActionResult Edit(Guid CourseChapterID)
- {
- return View();
- }
- [HttpPost]
- public ActionResult GetChaperTree(Guid CoursematerialID)
- {
- var tree = new List<TreeItem>();
- tree.Add(new TreeItem() { id = "", text = "顶层" });
- var allChaper = ICourseBuildServices.GetCourseChapterList(CoursematerialID);
- tree[0].children = allChaper.Where(r => r.ParentCourseChapterID == null).OrderBy(x => x.OrderID)
- .Select(x => new TreeItem
- {
- id = x.CourseChapterID.ToString(),
- text = x.Name,
- attributes = new ChaperTree { parentId = "", orderId = x.OrderID, videoTypeID = x.VideoTypeID, outerVideoUrl = x.OuterVideoUrl }
- }).ToList();
- tree[0].children.ForEach(x => BindChaperTreeChildren(allChaper, x));
- return Json(tree);
- }
- private void BindChaperTreeChildren(IList<CourseChapterView> allChapter, TreeItem treeItem)
- {
- try
- {
- treeItem.children = allChapter.Where(x => x.ParentCourseChapterID != null && x.ParentCourseChapterID.Value.ToString() == treeItem.id)
- .OrderBy(x => x.OrderID)
- .Select(x => new TreeItem
- {
- id = x.CourseChapterID.ToString(),
- text = x.Name,
- attributes = new ChaperTree { parentId = x.ParentCourseChapterID.Value.ToString(), orderId = x.OrderID, videoTypeID = x.VideoTypeID, outerVideoUrl = x.OuterVideoUrl }
- }).ToList();
- }
- catch (Exception ex)
- {
- throw ex;
- }
- treeItem.children.ForEach(x => BindChaperTreeChildren(allChapter, x));
- }
- [HttpPost]
- public ActionResult GetVideoList(int page, int rows, string Name)
- {
- var result = ICourseBuildServices.GetVideoList(page - 1, rows, Name);
- return Json(result);
- }
- }
- }
|