Esempio n. 1
0
 //
 // GET: /RankList/
 //获取所有用户的发表知识数量的排行
 public string GetMemberRank()
 {
     UserService userService = new UserService();
     AriticleService ariticleSerivice = new AriticleService();
     List<User> list = userService.GetMemerList();
     List<RankListMember> rkmList = new List<RankListMember>();
     for (int i = 0; i < list.Count; i++) {
         RankListMember t = new RankListMember();
         t.RealName = list[i].RealName;
         t.ariticleCount = ariticleSerivice.GetAriticleCount(list[i].Id);
         rkmList.Add(t);
     }
     //对结果排序
     var queryResults =
             from n in rkmList
             orderby n.ariticleCount descending
             select n;
     List<RankListMember> rkmList2 = new List<RankListMember>();
     foreach (var n in queryResults) {
         rkmList2.Add(n);
     }
     string result = JsonConvert.SerializeObject(rkmList2);
     return result;
 }