Example #1
0
 /// <summary>
 /// 添加视频分类
 /// </summary>
 /// <param name="videoCategoryInfo">视频分类实体</param>
 public void InsertVideoCategory(VideoCategoryInfo videoCategoryInfo)
 {
     using (MongoDB mongoDB = new MongoDB())
     {
         mongoDB.GetCollection <VideoCategoryInfo>().Insert(videoCategoryInfo);
     }
 }
Example #2
0
        public JsonResult VideoNew(VideoInfo videoInfo)
        {
            if (videoInfo == null)
            {
                return(Json(new MessageInfo {
                    Success = false, Message = "信息错误."
                }));
            }
            if (string.IsNullOrEmpty(videoInfo.Name))
            {
                return(Json(new MessageInfo {
                    Success = false, Message = "请输入名称."
                }));
            }
            if (string.IsNullOrEmpty(videoInfo.VideoCategoryID))
            {
                return(Json(new MessageInfo {
                    Success = false, Message = "请选择视频分类."
                }));
            }
            VideoCategoryInfo videoCategoryInfo = Lottery.DatabaseProvider.Instance().GetVideoCategoryByID(videoInfo.VideoCategoryID);

            if (videoCategoryInfo == null)
            {
                return(Json(new MessageInfo {
                    Success = false, Message = "视频分类不存在."
                }));
            }
            VideoCategoryInfo videoCategoryInfoChild = Lottery.DatabaseProvider.Instance().GetVideoCategoryByPID(videoInfo.VideoCategoryID);

            if (videoCategoryInfoChild != null)
            {
                return(Json(new MessageInfo {
                    Success = false, Message = "视频分类下有子分类,请选择子分类."
                }));
            }
            if (string.IsNullOrEmpty(videoInfo.File))
            {
                return(Json(new MessageInfo {
                    Success = false, Message = "请输入文件名."
                }));
            }
            VideoInfo videoInfoJudge = Lottery.DatabaseProvider.Instance().GetVideoByNameAndCategoryID(videoInfo.Name, videoInfo.VideoCategoryID);

            if (videoInfoJudge != null)
            {
                return(Json(new MessageInfo {
                    Success = false, Message = "名称已被专用,请换个试试."
                }));
            }
            videoInfo.ID                = Guid.NewGuid().ToString();
            videoInfo.Date              = DateTime.Now;
            videoInfo.Status            = Convert.ToInt16(EnumInfo.Status.Start);
            videoInfo.VideoCategoryName = videoCategoryInfo.Name;
            Lottery.DatabaseProvider.Instance().InsertVideo(videoInfo);
            return(Json(new MessageInfo {
                Success = true, Message = "添加成功.", Model = videoInfo
            }));
        }
Example #3
0
 /// <summary>
 /// 修改视频分类
 /// </summary>
 /// <param name="videoCategoryInfo">视频分类编号</param>
 public void UpdateVideoCategory(VideoCategoryInfo videoCategoryInfo)
 {
     using (MongoDB mongoDB = new MongoDB())
     {
         var collection = mongoDB.GetCollection <VideoCategoryInfo>();
         collection.Update(videoCategoryInfo, u => u.ID == videoCategoryInfo.ID);
     }
 }
Example #4
0
        public JsonResult VideoCategoryEdit(VideoCategoryInfo videoCategoryInfo)
        {
            if (videoCategoryInfo == null)
            {
                return(Json(new MessageInfo {
                    Success = false, Message = "信息错误."
                }));
            }
            if (string.IsNullOrEmpty(videoCategoryInfo.ID))
            {
                return(Json(new MessageInfo {
                    Success = false, Message = "视频分类编号错误."
                }));
            }
            VideoCategoryInfo videoCategoryInfoEdit = Lottery.DatabaseProvider.Instance().GetVideoCategoryByID(videoCategoryInfo.ID);

            if (videoCategoryInfoEdit == null)
            {
                return(Json(new MessageInfo {
                    Success = false, Message = "视频分类不存在"
                }));
            }
            if (string.IsNullOrEmpty(videoCategoryInfo.Name))
            {
                return(Json(new MessageInfo {
                    Success = false, Message = "请输入名称."
                }));
            }
            if (string.IsNullOrEmpty(videoCategoryInfo.PID))
            {
                return(Json(new MessageInfo {
                    Success = false, Message = "请选择上级编号."
                }));
            }
            if (videoCategoryInfoEdit.PID != videoCategoryInfo.PID)
            {
                if (Lottery.DatabaseProvider.Instance().GetVideoCategoryByPID(videoCategoryInfo.ID) != null)
                {
                    return(Json(new MessageInfo {
                        Success = false, Message = "此分类下有子级,不能修改."
                    }));
                }
                else
                {
                    VideoCategoryInfo videoCategoryInfoParent = Lottery.DatabaseProvider.Instance().GetVideoCategoryByID(videoCategoryInfo.PID);
                    videoCategoryInfoEdit.Level = videoCategoryInfoParent == null ? 1 : videoCategoryInfoParent.Level + 1;
                }
            }
            videoCategoryInfoEdit.Name = videoCategoryInfo.Name;
            videoCategoryInfoEdit.Move = videoCategoryInfoEdit.PID == videoCategoryInfo.PID ? false : true;
            videoCategoryInfoEdit.PID  = videoCategoryInfo.PID;
            videoCategoryInfoEdit.Memo = videoCategoryInfo.Memo;
            Lottery.DatabaseProvider.Instance().UpdateVideoCategory(videoCategoryInfoEdit);
            return(Json(new MessageInfo {
                Success = true, Message = "修改成功.", Model = videoCategoryInfoEdit
            }));
        }
Example #5
0
        //视频分类列表
        public ActionResult VideoCategoryList(VideoCategoryInfo videoCategoryInfo, PageInfo pageInfo)
        {
            if (pageInfo == null)
            {
                pageInfo = new PageInfo();
            }
            IList <VideoCategoryInfo> videoCategoryInfos = Lottery.DatabaseProvider.Instance().GetVideoCategory(videoCategoryInfo);

            videoCategoryInfos = ViewCategoryTree("0", videoCategoryInfos, null);
            return(View(videoCategoryInfos));
        }
Example #6
0
 /// <summary>
 /// 获取视频分类
 /// </summary>
 /// <param name="videoCategoryInfo">视频分类实体</param>
 /// <param name="pageInfo">分页实体</param>
 /// <returns></returns>
 public IList <VideoCategoryInfo> GetVideoCategory(VideoCategoryInfo videoCategoryInfo)
 {
     using (MongoDB mongoDB = new MongoDB())
     {
         var collection = mongoDB.GetCollection <VideoCategoryInfo>();
         var query      = from user in collection.Linq() select user;
         if (videoCategoryInfo != null && !string.IsNullOrEmpty(videoCategoryInfo.ID))
         {
             query = query.Where(u => u.ID.Contains(videoCategoryInfo.ID));
         }
         if (videoCategoryInfo != null && !string.IsNullOrEmpty(videoCategoryInfo.Name))
         {
             query = query.Where(u => u.Name.Contains(videoCategoryInfo.Name));
         }
         return(query.OrderByDescending(u => u.Date).ToList <VideoCategoryInfo>());
     }
 }
Example #7
0
        public JsonResult VideoCategoryNew(VideoCategoryInfo videoCategoryInfo)
        {
            if (videoCategoryInfo == null)
            {
                return(Json(new MessageInfo {
                    Success = false, Message = "信息错误."
                }));
            }
            if (string.IsNullOrEmpty(videoCategoryInfo.Name))
            {
                return(Json(new MessageInfo {
                    Success = false, Message = "请输入名称."
                }));
            }
            if (string.IsNullOrEmpty(videoCategoryInfo.PID))
            {
                return(Json(new MessageInfo {
                    Success = false, Message = "请选择上级."
                }));
            }
            VideoCategoryInfo videoCategoryInfoJudge = Lottery.DatabaseProvider.Instance().GetVideoCategoryByNameAndPID(videoCategoryInfo.Name, videoCategoryInfo.PID);

            if (videoCategoryInfoJudge != null)
            {
                return(Json(new MessageInfo {
                    Success = false, Message = "名称已被专用,请换个试试."
                }));
            }
            videoCategoryInfo.ID    = Guid.NewGuid().ToString();
            videoCategoryInfo.Level = 1;
            if (videoCategoryInfo.PID != "0")
            {
                VideoCategoryInfo videoCategoryInfoParent = Lottery.DatabaseProvider.Instance().GetVideoCategoryByID(videoCategoryInfo.PID);
                videoCategoryInfo.Level = videoCategoryInfoParent == null ? videoCategoryInfo.Level : videoCategoryInfoParent.Level + 1;
            }
            videoCategoryInfo.Date   = DateTime.Now;
            videoCategoryInfo.Status = Convert.ToInt16(EnumInfo.Status.Start);
            Lottery.DatabaseProvider.Instance().InsertVideoCategory(videoCategoryInfo);
            return(Json(new MessageInfo {
                Success = true, Message = "添加成功.", Model = videoCategoryInfo
            }));
        }
Example #8
0
        public JsonResult VideoEdit(VideoInfo videoInfo)
        {
            if (videoInfo == null)
            {
                return(Json(new MessageInfo {
                    Success = false, Message = "信息错误."
                }));
            }
            if (string.IsNullOrEmpty(videoInfo.ID))
            {
                return(Json(new MessageInfo {
                    Success = false, Message = "视频编号错误."
                }));
            }
            VideoInfo videoInfoEdit = Lottery.DatabaseProvider.Instance().GetVideoByID(videoInfo.ID);

            if (videoInfoEdit == null)
            {
                return(Json(new MessageInfo {
                    Success = false, Message = "视频不存在"
                }));
            }
            if (string.IsNullOrEmpty(videoInfo.Name))
            {
                return(Json(new MessageInfo {
                    Success = false, Message = "请输入名称."
                }));
            }
            if (string.IsNullOrEmpty(videoInfo.VideoCategoryID))
            {
                return(Json(new MessageInfo {
                    Success = false, Message = "请选择视频分类."
                }));
            }
            VideoCategoryInfo videoCategoryInfo = Lottery.DatabaseProvider.Instance().GetVideoCategoryByID(videoInfo.VideoCategoryID);

            if (videoCategoryInfo == null)
            {
                return(Json(new MessageInfo {
                    Success = false, Message = "视频分类不存在."
                }));
            }
            VideoCategoryInfo videoCategoryInfoChild = Lottery.DatabaseProvider.Instance().GetVideoCategoryByPID(videoInfo.VideoCategoryID);

            if (videoCategoryInfoChild != null)
            {
                return(Json(new MessageInfo {
                    Success = false, Message = "视频分类下有子分类,请选择子分类."
                }));
            }
            IList <VideoInfo> videoInfos = Lottery.DatabaseProvider.Instance().GetVideo(new VideoInfo {
                NameEqual = videoInfo.Name, VideoCategoryID = videoInfo.VideoCategoryID
            }, null);

            if (videoInfos != null && videoInfos.Count > 1)
            {
                return(Json(new MessageInfo {
                    Success = false, Message = "此名称已被使用,请换个试试."
                }));
            }
            if (string.IsNullOrEmpty(videoInfo.File))
            {
                return(Json(new MessageInfo {
                    Success = false, Message = "请输入文件名."
                }));
            }
            videoInfoEdit.Name = videoInfo.Name;
            videoInfoEdit.File = videoInfo.File;
            videoInfoEdit.VideoCategoryName = videoCategoryInfo.Name;
            Lottery.DatabaseProvider.Instance().UpdateVideo(videoInfoEdit);
            return(Json(new MessageInfo {
                Success = true, Message = "修改成功.", Model = videoInfoEdit
            }));
        }