Example #1
0
        /*
         * [HttpPost]
         * public ActionResult SetRole(int userID)
         * {
         *  //var currentSetRoleUser = _userInfoService.LoadEntities(c => c.ID == ID).FirstOrDefault();
         *  ////把当前要设置角色的用户传递到前台
         *  //ViewData.Model = currentSetRoleUser;
         *  ////前台需要所有的角色的信息,这时候我们就需要引用到所有的角色信息,便要定义角色类型
         *  ////得到枚举中的没有被删除的信息
         *  //const int deleteNorMal = (int)DeletionStateCodeEnum.Normal;
         *  //var allRoles = _roleInfoService.LoadEntities(c => c.DeletionStateCode == deleteNorMal).ToList();
         *  ////动态的MVC特性,传递角色的全部信息
         *  //ViewBag.AllRoles = allRoles;
         *  ////往前台传递用户已经关联了的角色信息
         *  //if (currentSetRoleUser != null)
         *  //    ViewBag.ExtIsRoleIDS = (from r in currentSetRoleUser.R_UserInfo_Role
         *  //                            //当前用户和角色中间表的集合数据
         *  //                            select r.RoleID).ToList();
         *  ViewBag.AllRoles = "1,2".Split(new char[] { ',' }).ToList();
         *  ViewBag.ExtIsRoleIDS = "";
         *  return View();
         * }
         *
         * public ActionResult SetRole123()
         * {
         *  return Content("OK");
         * }
         *
         * public ActionResult SetRole2(int userID)
         * {
         *  //return Content("OK");
         *  return Json("{id:1,name:234}", JsonRequestBehavior.AllowGet);
         * }
         *
         * public ActionResult GetUserInfoByID2(string id)
         * {
         *  IUserService userService = UnityHelper.UnityResolve<IUserService>();
         *  var data = userService.GetUserByID(id);
         *  return Json(data, JsonRequestBehavior.AllowGet);
         * }
         */

        /// <summary>
        /// 为用户设置角色
        /// </summary>
        /// <param name="ID">获取当前选择的用户的ID</param>
        /// <returns>返回根据这个ID查到的用户信息</returns>
        public ActionResult SetRole(string ID)
        {
            IUserService userService        = UnityHelper.UnityResolve <IUserService>();
            var          currentSetRoleUser = userService.GetUserByID(ID);

            ViewData.Model = currentSetRoleUser;
            IUserroleService userroleService = UnityHelper.UnityResolve <IUserroleService>();

            ViewBag.ExtIsRoleIDS = userroleService.GetUserRoleListByUserID(ID);

            IRoleService roleService = UnityHelper.UnityResolve <IRoleService>();
            var          allRoles    = roleService.GetAllRoleList();

            ViewBag.AllRoles = allRoles;
            return(View());
        }