当前位置: 首页>>代码示例>>C#>>正文


C# UserService.FindById方法代码示例

本文整理汇总了C#中UserService.FindById方法的典型用法代码示例。如果您正苦于以下问题:C# UserService.FindById方法的具体用法?C# UserService.FindById怎么用?C# UserService.FindById使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UserService的用法示例。


在下文中一共展示了UserService.FindById方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: getMemberById

        //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;
            }
        }
开发者ID:hiyouth,项目名称:R2.RRDL,代码行数:52,代码来源:MemberManageController.cs

示例2: GetAriticleByTreeNodeId

 /// <summary>
 ///     通过TreeNodeId获取Ariticle
 /// </summary>
 /// <param name="_modeType"></param>
 /// <param name="_nodeId"></param>
 /// <param name="_xmlUrl"></param>
 /// <param name="_nodeInfo"></param>
 /// <returns></returns>
 public ActionResult GetAriticleByTreeNodeId(string treeNodeId,string userId) 
 {
     using (RRDLEntities db = new RRDLEntities())
     {
         Tree tree = new Tree(db);
         Ariticle ariticle = tree.GetTreeNodeById(Int32.Parse(treeNodeId)).Ariticle;
         PraiseRepository pr = new PraiseRepository();
         //如果是叶子节点,传递知识内容到前台
         if (ariticle != null)
         {
             AriticleViewModel avm = new AriticleViewModel(ariticle);
             UserService us = new UserService();
             User author = us.FindById(ariticle.UserId);
             avm.author = author.NickName;
             string time1 = ariticle.Createtime.ToLongDateString();
             string time2 = ariticle.Createtime.ToLongTimeString();
             avm.Createtime = time1 + "  " + time2;
             //avm.PraiseCount = pr.FindByAriticleID(ariticle.Id).PraiseCount;
             avm.Id = ariticle.Id;
             AriticleService ars = new AriticleService();
             string isShow = "";
                 if(userId == "vistor"){
                     userId = null;
                 }
                 if (ars.GetAriticleVisibilityByUser(ariticle.Id, userId))
                 {
                     bool falg = ars.GetAriticleVisibilityByUser(ariticle.Id, userId);
                     isShow = "true";
                 }
                 else
                 {
                     bool falg = ars.GetAriticleVisibilityByUser(ariticle.Id, userId);
                     isShow = "false";
                 }
             User user = us.FindById(userId);
             if(user!=null && user.ContentGroupId == 2){
                 isShow = "true";
             }
             string result = JsonConvert.SerializeObject(avm);
             result = result + "ThisAriticleIsShowForThisUser" + isShow;
             return Content(result);
         }
         else
         {
             return Content("NotLeaf");
         }
     }
 }
开发者ID:hiyouth,项目名称:R2.RRDL,代码行数:56,代码来源:TreeViewController.cs

示例3: PassTheUser

 public string PassTheUser(string userId, int userGroupId)
 {            
     UserService userservice = new UserService();
     User user = userservice.FindById(userId);
     user.ApproveStatus = EnumUserApproveStatus.Approved;
     user.AuthorityCategory = EnumUserCategory.Membership;
     user.ContentGroupId = userGroupId;
     userservice.UpdateUser(user);
     return "success";
 }
开发者ID:hiyouth,项目名称:R2.RRDL,代码行数:10,代码来源:UserVerifyController.cs

示例4: GetAUserInfo

 public string GetAUserInfo(string userId) {
     UserService userservice = new UserService();
     User user = userservice.FindById(userId);
     UserViewModel uvm = new UserViewModel();
     uvm.RegisterName = user.RegisterName;
     uvm.RealName = user.RealName;
     uvm.NickName = user.NickName;
     uvm.Gender = user.Gender;
     uvm.PersonalDescription = user.PersonalDescription;
     string result = JsonConvert.SerializeObject(uvm);
     return result;
 }
开发者ID:hiyouth,项目名称:R2.RRDL,代码行数:12,代码来源:UserVerifyController.cs

示例5: KnowledgeModify

        public string KnowledgeModify(string ariticleJson)
        {
            using (RRDLEntities db = new RRDLEntities())
            {
                AriticleJson ariticlejson = (AriticleJson)JsonConvert.DeserializeObject(ariticleJson, typeof(AriticleJson));

                AriticleService ars = new AriticleService(db);
                Ariticle ariticle = ars.FindById(ariticlejson.Id);

                //添加标题
                ariticle.Title = ariticlejson.title;
                //添加内容
                //ariticle.UGC = System.Web.HttpUtility.UrlDecode(ariticlejson.UGC);
                ariticlejson.UGC = System.Web.HttpUtility.UrlDecode(ariticlejson.UGC);
                ariticlejson.UGC = ariticlejson.UGC.Replace("CodeReplacePlus", "+");
                ariticle.UGC = ariticlejson.UGC;
                //添加标签
                string[] tlist = ariticlejson.tag.Split(new char[] { ',' });
                List<AriticleTag> tagList = new List<AriticleTag>();
                for (int i = 0; i < tlist.Length; i++)
                {
                    AriticleTag ariticletag = new AriticleTag();
                    ariticletag.Title = tlist[i];
                    ariticletag.AriticleId = ariticlejson.Id;
                    // ariticletag.Article = ariticle;
                    tagList.Add(ariticletag);
                }
                AriticleTagRepository tagRepository = new AriticleTagRepository(db);
                tagRepository.UpdateAllRelatedAriticleId(ariticle.Id, tagList);
                //创建一个新节点
                TreeNode treeNode = new TreeNode(Int32.Parse(ariticlejson.treeNodeParentId), ariticlejson.title);
                treeNode.Ariticle = ariticle;
                Tree tree = new Tree(db);
                tree.AddTreeNode(treeNode);
                //删除旧节点
                TreeNode oldtreeNode = tree.SearchByAriticle(ariticle.Id);
                tree.Drop(oldtreeNode);
                //创建不可见分组信息数组
                string[] inlist = ariticlejson.invisibility.Split(new char[] { ';' });
                List<int> invisiblityGroup = new List<int>();
                for (int i = 0; i < inlist.Length - 1; i++)
                {
                    invisiblityGroup.Add(Int32.Parse(inlist[i]));
                }
                //判断是否为管理员或超级管理员修改,审核状态保持已通过审核
                UserService us = new UserService();
                User user = us.FindById(ariticlejson.UserId);
                if (user.AuthorityCategory != EnumUserCategory.Administrator && user.AuthorityCategory != EnumUserCategory.Superman)
                {
                    ariticle.Approve.ApproveStatus = EnumAriticleApproveStatus.UnApproved;
                }
                else {
                    ariticle.Approve.ApproveStatus = EnumAriticleApproveStatus.Approved;
                }
                ars.UpdateAriticle(ariticle, invisiblityGroup);
                db.SaveChanges();
                return "success";
            }
        }
开发者ID:hiyouth,项目名称:R2.RRDL,代码行数:59,代码来源:PersonalCenterController.cs

示例6: UpdateUser

 //传入用户名和密码,更新用户密码
 public string UpdateUser(string userId, string password)
 {
     string id = userId;
     UserService uservice = new UserService();
     User user = uservice.FindById(id);
     user.Password = password;
     uservice.UpdateUser(user);
     return "success";
 }
开发者ID:hiyouth,项目名称:R2.RRDL,代码行数:10,代码来源:PersonalCenterController.cs

示例7: GetUserById

 public string GetUserById(string userId)
 {
     using (RRDLEntities db = new RRDLEntities())
     {
         UserService us = new UserService();
         User user = us.FindById(userId);
         UserViewModel uvm = new UserViewModel();
         uvm.NickName = user.NickName;
         uvm.RealName = user.RealName;
         uvm.RegisterName = user.RegisterName;
         uvm.Category = getAuthorityCategory(user.AuthorityCategory);
         int ugid = (int)user.ContentGroupId;
         UserGroupService ugs = new UserGroupService();
         UserGroup ug = ugs.FindById(ugid);
         uvm.UserGroup = ug.Title;
         uvm.CreateTime = user.Createtime.ToString();
         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);
         uvm.approvedArticleCount = approvedcount;
         uvm.allArticleCount = allcount;
         string result = JsonConvert.SerializeObject(uvm);
         return result;
     }
 }
开发者ID:hiyouth,项目名称:R2.RRDL,代码行数:32,代码来源:PersonalCenterController.cs

示例8: ModifyMemberAttrs

 //传入新的用户属性,将后台用户属性更改成传入的内容
 public string ModifyMemberAttrs(string userId, string userGroupId, string userAuthorityCategory)
 {
     UserService userservice = new UserService();
     User user = userservice.FindById(userId);
     user.ApproveStatus = EnumUserApproveStatus.Approved;
     user.AuthorityCategory = (EnumUserCategory)Convert.ToInt32(userAuthorityCategory);
     user.ContentGroupId = Convert.ToInt32(userGroupId);
     userservice.UpdateUser(user);
     return "success";           
 }
开发者ID:hiyouth,项目名称:R2.RRDL,代码行数:11,代码来源:MemberManageController.cs


注:本文中的UserService.FindById方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。