/// <summary> /// 获取用户 /// </summary> /// <param name="userInfo">用户实体</param> /// <param name="pageInfo">分页实体</param> /// <returns></returns> public IList <UserInfo> GetUser(UserInfo userInfo, PageInfo pageInfo) { using (MongoDB mongoDB = new MongoDB()) { var collection = mongoDB.GetCollection <UserInfo>(); var query = from user in collection.Linq() select user; if (userInfo != null && !string.IsNullOrEmpty(userInfo.ID)) { query = query.Where(u => u.ID.Contains(userInfo.ID)); } if (userInfo != null && !string.IsNullOrEmpty(userInfo.Name)) { query = query.Where(u => u.Name.Contains(userInfo.Name)); } if (userInfo != null && !string.IsNullOrEmpty(userInfo.NameEqual)) { query = query.Where(u => u.Name == userInfo.NameEqual); } if (userInfo != null && !string.IsNullOrEmpty(userInfo.Email)) { query = query.Where(u => u.Email.Contains(userInfo.Email)); } if (userInfo != null && !string.IsNullOrEmpty(userInfo.EmailEqual)) { query = query.Where(u => u.Email == userInfo.EmailEqual); } return(query.OrderByDescending(u => u.Date).GetPagingList <UserInfo>(pageInfo)); } }
/// <summary> /// 获取用户 /// </summary> /// <param name="email">用户邮箱</param> /// <returns></returns> public UserInfo GetUserByEmail(string email) { using (MongoDB mongoDB = new MongoDB()) { return(mongoDB.GetCollection <UserInfo>().FindOne(u => u.Email == email)); } }
/// <summary> /// 获取用户 /// </summary> /// <param name="email">邮箱</param> /// <param name="password">密码</param> /// <returns></returns> public UserInfo GetUser(string email, string password) { using (MongoDB mongoDB = new MongoDB()) { return(mongoDB.GetCollection <UserInfo>().FindOne(u => u.Email == email && u.Password == password)); } }
/// <summary> /// 添加用户 /// </summary> /// <param name="userInfo">用户实体</param> public void InsertUser(UserInfo userInfo) { using (MongoDB mongoDB = new MongoDB()) { mongoDB.GetCollection <UserInfo>().Insert(userInfo); } }
/// <summary> /// 获取用户 /// </summary> /// <param name="ID">用户编号</param> /// <returns></returns> public UserInfo GetUserByID(string ID) { using (MongoDB mongoDB = new MongoDB()) { return(mongoDB.GetCollection <UserInfo>().FindOne(u => u.ID == ID)); } }
/// <summary> /// 获取视频 /// </summary> /// <param name="name">视频名称</param> /// <param name="videoCategoryID">视频分类编号</param> /// <returns></returns> public VideoInfo GetVideoByNameAndCategoryID(string name, string videoCategoryID) { using (MongoDB mongoDB = new MongoDB()) { return(mongoDB.GetCollection <VideoInfo>().FindOne(u => u.Name == name && u.VideoCategoryID == videoCategoryID)); } }
/// <summary> /// 获取视频 /// </summary> /// <param name="videoInfo">视频实体</param> /// <param name="pageInfo">分页实体</param> /// <returns></returns> public IList <VideoInfo> GetVideo(VideoInfo videoInfo, PageInfo pageInfo) { using (MongoDB mongoDB = new MongoDB()) { var collection = mongoDB.GetCollection <VideoInfo>(); var query = from video in collection.Linq() select video; if (videoInfo != null && !string.IsNullOrEmpty(videoInfo.ID)) { query = query.Where(u => u.ID.Contains(videoInfo.ID)); } if (videoInfo != null && !string.IsNullOrEmpty(videoInfo.Name)) { query = query.Where(u => u.Name.Contains(videoInfo.Name)); } if (videoInfo != null && !string.IsNullOrEmpty(videoInfo.NameEqual)) { query = query.Where(u => u.Name == videoInfo.NameEqual); } if (videoInfo != null && !string.IsNullOrEmpty(videoInfo.File)) { query = query.Where(u => u.File.Contains(videoInfo.File)); } if (videoInfo != null && !string.IsNullOrEmpty(videoInfo.VideoCategoryID)) { query = query.Where(u => u.VideoCategoryID == videoInfo.VideoCategoryID); } return(query.OrderByDescending(u => u.Date).GetPagingList <VideoInfo>(pageInfo)); } }
/// <summary> /// 获取视频 /// </summary> /// <param name="ID">视频编号</param> /// <returns></returns> public VideoInfo GetVideoByID(string ID) { using (MongoDB mongoDB = new MongoDB()) { return(mongoDB.GetCollection <VideoInfo>().FindOne(u => u.ID == ID)); } }
/// <summary> /// 获取视频 /// </summary> /// <param name="name">视频名称</param> /// <returns></returns> public VideoInfo GetVideoByName(string name) { using (MongoDB mongoDB = new MongoDB()) { return(mongoDB.GetCollection <VideoInfo>().FindOne(u => u.Name == name)); } }
/// <summary> /// 添加视频 /// </summary> /// <param name="videoInfo">视频实体</param> public void InsertVideo(VideoInfo videoInfo) { using (MongoDB mongoDB = new MongoDB()) { mongoDB.GetCollection <VideoInfo>().Insert(videoInfo); } }
/// <summary> /// 获取视频分类 /// </summary> /// <param name="name">视频分类父级编号</param> /// <returns></returns> public VideoCategoryInfo GetVideoCategoryByPID(string PID) { using (MongoDB mongoDB = new MongoDB()) { return(mongoDB.GetCollection <VideoCategoryInfo>().FindOne(u => u.PID == PID)); } }
/// <summary> /// 修改用户 /// </summary> /// <param name="userInfo">用户编号</param> public void UpdateUser(UserInfo userInfo) { using (MongoDB mongoDB = new MongoDB()) { var collection = mongoDB.GetCollection <UserInfo>(); collection.Update(userInfo, u => u.ID == userInfo.ID); } }
/// <summary> /// 删除用户 /// </summary> /// <param name="ID">用户编号</param> public void DeleteUser(string ID) { using (MongoDB mongoDB = new MongoDB()) { var collection = mongoDB.GetCollection <UserInfo>(); collection.Remove(u => u.ID == ID); } }
/// <summary> /// 修改视频 /// </summary> /// <param name="videoInfo">视频编号</param> public void UpdateVideo(VideoInfo videoInfo) { using (MongoDB mongoDB = new MongoDB()) { var collection = mongoDB.GetCollection <VideoInfo>(); collection.Update(videoInfo, u => u.ID == videoInfo.ID); } }
/// <summary> /// 删除视频分类 /// </summary> /// <param name="ID">视频分类编号</param> public void DeleteVideoCategory(string ID) { using (MongoDB mongoDB = new MongoDB()) { var collection = mongoDB.GetCollection <VideoCategoryInfo>(); collection.Remove(u => u.ID == ID); } }
/// <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>()); } }