Ejemplo n.º 1
0
 //参数 用户名 每页条数  页码
 public ActionResult ShowOwnKnowledgeItem(string userId, int numOnePage, int pageIndex)
 {
     using (RRDLEntities db = new RRDLEntities())
     {              
         AriticleService articleService = new AriticleService();
         List<Ariticle> list = new List<Ariticle>();
         list = articleService.FindAriticlesByUser(userId, numOnePage, pageIndex, db);
         int n = list.Count;
         AriticleService articleService1 = new AriticleService();
         int totalCount = articleService1.GetAriticleCount(userId);
         List<AriticleViewModel> ariticleList = new List<AriticleViewModel>();
         for (int i = 0; i < n; i++)
         {
             AriticleViewModel temp = new AriticleViewModel(list[i]);
             temp.ApproveStatus = list[i].Approve.ApproveStatus;
             temp.Id = list[i].Id;
             string time1 = list[i].Createtime.ToLongDateString();
             string time2 = list[i].Createtime.ToLongTimeString();
             temp.Createtime = time1 + "  " + time2;
             temp.Title = list[i].Title;
             if (list[i].UGC.Length > 300)
             {
                 temp.UGC = list[i].UGC.Substring(0, 300);
             }
             else
             {
                 temp.UGC = list[i].UGC;
             }
             // temp.Tags = list[i].Tags;
             temp.Title = list[i].Title;
             temp.User = null;
             ariticleList.Add(temp);
         }
         string length = (ariticleList.Count).ToString();
         string result = JsonConvert.SerializeObject(ariticleList);
         result = result + "ContentAndCount" + totalCount;
         return Content(result);
     }
 }