Ejemplo n.º 1
0
        public ActionResult ChangeAction()
        {
            int userid = Request["userid"] != null?int.Parse(Request["userid"]) : 0;

            int actionid = Request["actionid"] != null?int.Parse(Request["actionid"]) : 0;

            bool isAllow = Request["radiovalue"].ToString() == "true" ? true : false;
            R_UserInfo_ActionInfo useraction = R_UserInfo_ActionInfoService.LoadEntities(u => u.UserInfoID == userid && u.ActionInfoID == actionid).FirstOrDefault();

            if (useraction == null)//R_UserInfo_ActionInfo表里未有该记录
            {
                //添加记录
                R_UserInfo_ActionInfo newuseraction = new R_UserInfo_ActionInfo
                {
                    UserInfoID   = userid,
                    ActionInfoID = actionid,
                    IsPass       = isAllow
                };
                R_UserInfo_ActionInfoService.AddEntity(newuseraction);
                return(Content("成功修改权限"));
            }
            else
            {
                //修改记录
                useraction.IsPass = isAllow;
                R_UserInfo_ActionInfoService.EditEntity(useraction);
                return(Content("成功修改权限"));
            }
        }
Ejemplo n.º 2
0
        public ActionResult ShowPermissions()
        {
            int id   = Request["id"] == null ? 0 : int.Parse(Request["id"]);//获取从userinfo/index传来的id值
            var user = UserInfoService.LoadEntities(u => u.ID == id).FirstOrDefault();

            ViewBag.userInfo = user;
            short deFlag      = (short)DeleteEnumType.Normal;
            var   permissions = ActionInfoService.LoadEntities(a => a.DelFlag == deFlag).ToList();//获取所有的权限,不采用延迟加载,避免嵌套循环时,出错(未关闭sqldatareader)

            ViewBag.permissions = permissions;
            var userAction = R_UserInfo_ActionInfoService.LoadEntities(u => u.UserInfoID == id).ToList();//获取该用户对应的权限记录

            ViewBag.userAction = userAction;
            return(View());
        }
Ejemplo n.º 3
0
        public ActionResult CleanAction()
        {
            int userid = Request["userid"] != null?int.Parse(Request["userid"]) : 0;

            int actionid = Request["actionid"] != null?int.Parse(Request["actionid"]) : 0;

            R_UserInfo_ActionInfo useraction = R_UserInfo_ActionInfoService.LoadEntities(u => u.UserInfoID == userid && u.ActionInfoID == actionid).FirstOrDefault();

            if (useraction == null)//R_UserInfo_ActionInfo表里未有该记录
            {
                return(Content("noexsit"));
            }
            else
            {
                if (R_UserInfo_ActionInfoService.DeleteEntity(useraction))//删除
                {
                    return(Content("ok"));
                }
                else
                {
                    return(Content("fail"));
                }
            }
        }