Exemplo n.º 1
0
        /// <summary>
        /// 检索功能入口函数
        /// </summary>
        /// <param name="_method">方法名称</param>
        /// <param name="condition">查询条件</param>
        /// <returns></returns>

        public string GetArcticle(string keyword, int numOnePage, int pageIndex,int leve,string userId)
        {

            using (RRDLEntities db = new RRDLEntities())
            {
                string newkey = System.Web.HttpUtility.UrlDecode(keyword).ToLower().Trim();
                AriticleService ars = new AriticleService(db);
                List<Ariticle> arlists = new List<Ariticle>();

                arlists = ars.SearchAriticles(newkey, numOnePage, pageIndex);
                int n = ars.SearchAllAriticlesCount(newkey);
                 switch (leve)
                 {   //游客
                     case -1:
                         arlists = isVisibilityUser(ars,arlists,null);
                         break;
                     //普通用户
                     case 1:
                         arlists = isVisibilityUser(ars, arlists, userId);
                         break;
                 }
                List<AriticleViewModel> avmlist = new List<AriticleViewModel>();
                avmlist = SimplifyAriticle(arlists);

                string result = JsonConvert.SerializeObject(avmlist);
                result = result + "ContentAndCount" + n;
                return result;
            }
            
        }