Exemplo n.º 1
0
        /// <summary>
        /// 获取我的收藏列表(含分页)
        /// </summary>
        /// <param name="userId">用户ID</param>
        /// <param name="like">模糊条件</param>
        /// <param name="orderBy">排序条件</param>
        /// <param name="pagesize">每页条数</param>
        /// <param name="pagecurrent">当前页</param>
        /// <param name="db"></param>
        /// <returns></returns>
        public List <MyCollectionByLike_Result> GetMyCollectList(string userId, string like, string orderBy, int pagesize, int pagecurrent, JSZX_ResourceEntities db)
        {
            List <MyCollectionByLike_Result> models = new List <MyCollectionByLike_Result>();

            try
            {
                DateTime dt = Convert.ToDateTime(DateTime.Now.ToString("yyyy/MM/dd"));

                var query = from t in db.MyCollectionByLike(like, dt) select t;
                //此用户的收藏资源
                query = query.Where(t => t.MyUserID.Equals(userId));
                //按收藏时间倒序
                if (orderBy == "0")
                {
                    query = query.OrderByDescending(t => t.CreateTime).OrderByDescending(t => t.num);
                }
                if (orderBy == "1")
                {
                    //评价次数
                    query = query.OrderByDescending(t => t.REVIEW_NUM).OrderByDescending(t => t.num);
                }
                else if (orderBy == "2")
                {
                    //最受好评
                    query = query.OrderByDescending(t => t.GRADE).OrderByDescending(t => t.num);
                }
                else if (orderBy == "3")
                {
                    //最多浏览
                    query = query.OrderByDescending(t => t.PAGE_VIEW_NUM).OrderByDescending(t => t.num);
                }
                else if (orderBy == "4")
                {
                    //最多下载
                    query = query.OrderByDescending(t => t.DOWNLOAD_NUM).OrderByDescending(t => t.num);
                }
                //默认按收藏时间倒序
                else
                {
                    query = query.OrderByDescending(t => t.CreateTime).OrderByDescending(t => t.num);
                }
                //获取当前页的数据
                models = query.Skip((pagecurrent - 1) * pagesize).Take(pagesize).ToList();
            }
            catch (Exception ex)
            {
                clsLog.ErrorLog("ResourceList", "GetMyCollectList", "Error! " + ex.Message);
            }
            return(models);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 获取我的收藏总数
        /// </summary>
        /// <param name="userId">用户ID</param>
        /// <param name="like">模糊条件</param>
        /// <param name="db"></param>
        /// <returns></returns>
        public int GetMyCollectCount(string userId, string like, JSZX_ResourceEntities db)
        {
            int ret = 0;

            try
            {
                DateTime dt = Convert.ToDateTime(DateTime.Now.ToString("yyyy/MM/dd"));

                var query = from t in db.MyCollectionByLike(like, dt) select t;
                //此用户的收藏资源
                query = query.Where(t => t.MyUserID.Equals(userId));
                ret   = query.Count();
            }
            catch (Exception ex)
            {
                clsLog.ErrorLog("ResourceList", "GetMyCollectCount", "Error! " + ex.Message);
            }
            return(ret);
        }