C#视频管理接口方法的完整代码

  1  #region 3 视频管理  Video  
  2 
  3         //获取所有老师 
  4         public IActionResult GetAllLecturer()
  5         {
  6             LectuerOperate op = new LectuerOperate();
  7             List<Lectuer> list = op.GetQueryable()
  8                 .OrderByDescending(q=>q.Sort)
  9                 .ToList();
 10             return Json(list);
 11         }
 12 
 13         // 获取所有分类 C# 用AritcleInfo
 14         public IActionResult GetAllAritcleInfo()
 15         {
 16             VideoClassOperate op = new VideoClassOperate();
 17             List<VideoClass> list = op.GetQueryable() // 上下文方法,不用逻辑文件中去写。
 18                 .OrderByDescending(q => q.Sort)
 19                 .ToList();
 20             return Json(list);
 21 
 22         }
 23 
 24 
 25         // 获取所属分类。 所属讲师的枚举类。
 26         public IActionResult GetType_VideoCateID()
 27         {
 28             var list = Enums.GetSelList<Enums.VideoCateID>();
 29             return Json(list);
 30         }
 31 
 32 
 33 
 34 
 35         //获取分类类型,讲师
 36         public IActionResult Get_Video()
 37         {
 38             var list = Enums.GetSelList<Enums.VideoCateID>();
 39            
 40             return Json(list);
 41 
 42         }
 43         // 获取对象接口
 44          public IActionResult GetModel_Video(int id)
 45         {
 46             VideoOperate _context = new VideoOperate();
 47             var model = _context.GetModel(id);
 48             return Json(model);
 49         }
 50 
 51 
 52 
 53 
 54 
 55 
 56         //get列表    括号里面为()接收的参数 获取分页参数  
 57         public IActionResult GetList_Video(PageInfo info, string key,int? cateid)
 58         {
 59             VideoOperate op = new VideoOperate();
 60             // list集合.  获取到的分页数据放到变量list集合里面。 
 61             List<Video> list = op.GetPage(info, key, cateid);
 62             return JsonList(list, info);
 63         }
 64 
 65 
 66 
 67         // 定义添加方法
 68         public IActionResult Save_Video(Video model)
 69         {
 70             try
 71             {
 72                 VideoOperate op = new VideoOperate();
 73                 if (model.ID > 0)// 如果   循环变量 model  循环条件 ID > 0 ,执行下面的循环体内容 
 74                 {
 75                     Video oldmodel = op.GetModel(model.ID);
 76                     oldmodel.Title = model.Title;
 77                     oldmodel.Summary = model.Summary;
 78                     oldmodel.VideoUrl = model.VideoUrl;
 79                     oldmodel.ViewCount = model.ViewCount;
 80                     oldmodel.CommentCount = model.CommentCount;
 81                     oldmodel.CateID = model.CateID;
 82                     oldmodel.LabeList = model.LabeList;
 83                     oldmodel.LecID = model.LecID;
 84                     oldmodel.PublishTime = model.PublishTime;
 85                     oldmodel.IsTop = model.IsTop;
 86                     oldmodel.Isrecomment = model.Isrecomment;
 87                                       
 88                     oldmodel.CreateID = model.CreateID;
 89                     oldmodel.CreateTime = model.CreateTime;
 90 
 91 
 92                     if (op.Modify(oldmodel))
 93                         return Success("修改成功!");
 94                     return Error("修改失败!");
 95                 }
 96                 else//add
 97                 {
 98                     model.CreateTime = DateTime.Now;
 99                     if (op.Add(model))
100                         return Success("添加成功!");
101                     return Error("添加失败!");
102                 }
103             }
104             catch (Exception ex)
105             {
106                 return Error(ex);
107             }
108         }
109         //delete  删除的接口方法定义。 
110         public IActionResult Delete_Video(string ids)
111         {
112             try
113             {
114                 LectuerOperate op = new LectuerOperate();
115                 if (op.Delete(op.GetIDListFromStr(ids)))
116                     return Success("删除成功!");
117                 return Error("删除失败!");
118             }
119             catch (Exception ex)
120             {
121                 return Error(ex);
122             }
123         }
124 
125 
126 
127 
128 
129 
130 
131 
132 
133 
134         #endregion

 

posted @ 2021-07-20 10:26  优敏行  阅读(187)  评论(0)    收藏  举报