Exemplo n.º 1
0
 public string Add(string title) {
     UserGroup ug = new UserGroup();
     ug.Title = title;
     UserGroupService ugs = new UserGroupService();
     ugs.Add(ug);
     List<UserGroup> list = ugs.FindAll();
     UserGroupViewModel ugv = new UserGroupViewModel(list[list.Count-1]);
     string result = JsonConvert.SerializeObject(ugv);
     return result;
 }
Exemplo n.º 2
0
 //得到所有用户分组
 public string GetUserGroups() {
     UserGroupService ugs = new UserGroupService();
     List<UserGroup> list = ugs.FindAll();
     List<UserGroupViewModel> ugvList = new List<UserGroupViewModel>();
     for (int i = 0; i < list.Count; i ++ )
     {
         UserGroupViewModel ugv = new UserGroupViewModel(list[i]);
         ugvList.Add(ugv);
     }
     string result = JsonConvert.SerializeObject(ugvList);
     return result;
 }
Exemplo n.º 3
0
 public ActionResult UploadAriticle()
 {
     UserGroupService ugs = new UserGroupService();
     List<UserGroup> list = ugs.FindAll();
     List<UserGroupViewModel> ugvlist = new List<UserGroupViewModel>();
     UserGroupViewModel ugv;
     for (int i = 0; i < list.Count; i++)
     {
         ugv = new UserGroupViewModel(list[i]);
         ugvlist.Add(ugv);
     }
     string result = JsonConvert.SerializeObject(ugvlist);
     ViewBag.OpenString = result;
     return View();
 }
Exemplo n.º 4
0
 //动态获取当前数据库中的 组 列表
 public ActionResult GetGroups()
 {
     UserGroupService usergroup = new UserGroupService();
     List<UserGroup> usergrouplist = new List<UserGroup>();
     usergrouplist = usergroup.FindAll();
     List<UserGroupViewModel> ugvlist = new List<UserGroupViewModel>();
     UserGroupViewModel ugv;
     for (int i = 0; i < usergrouplist.Count; i++)
     {
         ugv = new UserGroupViewModel(usergrouplist[i]);
         ugvlist.Add(ugv);
     }
     //string resultlist = JsonConvert.SerializeObject(ugvlist);
     string result = JsonConvert.SerializeObject(ugvlist);
     return Content(result);
 }
Exemplo n.º 5
0
 public ActionResult ToKnowledgeModify(string ariticleId)
 {
     using (RRDLEntities db = new RRDLEntities())
     {
         AriticleService ars = new AriticleService(db);
         Ariticle ariticle = ars.FindById(ariticleId);
         AriticleViewModel avm = new AriticleViewModel(ariticle);
         List<AriticleVisibility> visibilityList = ars.GetAriticleVisibility(ariticle.Id);
         avm.Id = ariticle.Id;
         string result = JsonConvert.SerializeObject(avm);
         ViewBag.Ariticle = result;
         UserGroupService ugs = new UserGroupService();
         List<UserGroup> list = ugs.FindAll();
         List<UserGroupViewModel> ugvlist = new List<UserGroupViewModel>();
         UserGroupViewModel ugv;
         for (int i = 0; i < list.Count; i++)
         {
             ugv = new UserGroupViewModel(list[i]);
             ugvlist.Add(ugv);
         }
         string resultlist = JsonConvert.SerializeObject(ugvlist);
         ViewBag.OpenString = resultlist;
         Tree tree = new Tree();
         TreeNode treeNode = tree.SearchByAriticle(ariticle.Id);
         List<TreeNode> treelist = tree.GetTreeNodePath(treeNode);
         string treeresult = "";
         for (int i = treelist.Count - 1; i >= 0; i--)
         {
             treeresult = treeresult + treelist[i].Title + "TreePathSplit";
         }
         ViewBag.TreeId = treeNode.ParentId;
         ViewBag.TreePath = treeresult;
         VisibilityViewModel vvm = new VisibilityViewModel();
         List<VisibilityViewModel> vvlist = new List<VisibilityViewModel>();
         int count = ugs.FindAll().Count;
         if (count == visibilityList.Count)
         {
             ViewBag.visibilityList = "all";
         }
         else
         {
             for (int i = 0; i < visibilityList.Count; i++)
             {
                 vvm = new VisibilityViewModel();
                 vvm.Id = visibilityList[i].Id;
                 vvm.UserGroupId = visibilityList[i].UserGroupId;
                 vvlist.Add(vvm);
             }
             string vlist = JsonConvert.SerializeObject(vvlist);
             ViewBag.visibilityList = vlist;
         }
         string author = ariticle.User.NickName;
         string createTime = ariticle.Createtime.ToString();
         ViewBag.author = author;
         ViewBag.createTime = createTime;
         return View();
     }
 }
Exemplo n.º 6
0
        //public string getMemberById(string userId) {
        //    UserService userservice = new UserService();
        //    User user = userservice.FindById(userId);
        //    MemberViewModel mvm = new MemberViewModel(user);
        //    UserGroupService ugs = new UserGroupService();
        //    List<UserGroup> list = ugs.FindAll();
        //    string memberResult = JsonConvert.SerializeObject(mvm);
        //    List<UserGroupViewModel> ugvlist = new List<UserGroupViewModel>();
        //    UserGroupViewModel ugv;
        //    for (int i = 0; i < list.Count; i++)
        //    {
        //        ugv = new UserGroupViewModel(list[i]);
        //        ugvlist.Add(ugv);
        //    }
        //    string result = JsonConvert.SerializeObject(ugvlist);
        //    return memberResult+"MemberAndGroupList"+result;
        //}


        public string getMemberById(string userId)
        {
            using (RRDLEntities db = new RRDLEntities())
            {
                UserService userservice = new UserService();
                User user = userservice.FindById(userId);
                MemberViewModel mvm = new MemberViewModel(user);
                int approvedcount = 0;
                int allcount = 0;
                AriticleService ariticleService = new AriticleService();
                Expression<Func<Ariticle, bool>> condition =
                               a => a.Approve.ApproveStatus == EnumAriticleApproveStatus.Approved
                                   && a.UserId == user.Id;
                approvedcount = ariticleService.GetAriticleCount(condition);
                condition =
                        a => a.UserId == user.Id;
                allcount = ariticleService.GetAriticleCount(condition);
                mvm.approvedArticleCount = approvedcount;
                mvm.allArticleCount = allcount;
                UserGroupService ugs = new UserGroupService();
                List<UserGroup> list = ugs.FindAll();
                string memberResult = JsonConvert.SerializeObject(mvm);
                List<UserGroupViewModel> ugvlist = new List<UserGroupViewModel>();
                UserGroupViewModel ugv;
                for (int i = 0; i < list.Count; i++)
                {
                    ugv = new UserGroupViewModel(list[i]);
                    ugvlist.Add(ugv);
                }
                string result = JsonConvert.SerializeObject(ugvlist);
                return memberResult + "MemberAndGroupList" + result;
            }
        }