Ejemplo n.º 1
0
 /// <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));
     }
 }
Ejemplo n.º 2
0
 /// <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));
     }
 }
Ejemplo n.º 3
0
 /// <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));
     }
 }
Ejemplo n.º 4
0
 /// <summary>
 /// 添加用户
 /// </summary>
 /// <param name="userInfo">用户实体</param>
 public void InsertUser(UserInfo userInfo)
 {
     using (MongoDB mongoDB = new MongoDB())
     {
         mongoDB.GetCollection <UserInfo>().Insert(userInfo);
     }
 }
Ejemplo n.º 5
0
 /// <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));
     }
 }
Ejemplo n.º 6
0
 /// <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));
     }
 }
Ejemplo n.º 7
0
 /// <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));
     }
 }
Ejemplo n.º 8
0
 /// <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));
     }
 }
Ejemplo n.º 9
0
 /// <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));
     }
 }
Ejemplo n.º 10
0
 /// <summary>
 /// 添加视频
 /// </summary>
 /// <param name="videoInfo">视频实体</param>
 public void InsertVideo(VideoInfo videoInfo)
 {
     using (MongoDB mongoDB = new MongoDB())
     {
         mongoDB.GetCollection <VideoInfo>().Insert(videoInfo);
     }
 }
Ejemplo n.º 11
0
 /// <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));
     }
 }
Ejemplo n.º 12
0
 /// <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);
     }
 }
Ejemplo n.º 13
0
 /// <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);
     }
 }
Ejemplo n.º 14
0
 /// <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);
     }
 }
Ejemplo n.º 15
0
 /// <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);
     }
 }
Ejemplo n.º 16
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>());
     }
 }