Exemplo n.º 1
0
        public ActionResult AddRole(RoleAddEdit model)
        {
            //处理其他请求
            var ac = Request["actionName"] ?? "";

            if (ac != "")
            {
                return(OtherAction(ac));
            }

            if (ModelState.IsValid)
            {
                var user = Session[Constants.USER_KEY] as User;
                if (sysRoleBll.CheckRoleName(model.Name.Trim(), user.SysCorp.ID))
                {
                    ModelState.AddModelError("Name", "角色名已存在");
                    return(View());
                }
                model.Type    = false;
                model.Corp    = user.SysCorp.ID;
                model.Creator = user.SysOperator.ID;
                if (!sysRoleBll.AddRole(model))
                {
                    TempData["returnMsgType"] = "error";
                    TempData["returnMsg"]     = "新增失败";
                    //ModelState.AddModelError("errorresult", "新增失败");
                    return(View(model));
                }
                TempData["returnMsgType"] = "success";
                TempData["returnMsg"]     = "新增成功";
                return(RedirectToAction("Index", "Role"));
            }
            return(View(model));
        }