Beispiel #1
0
        public ActionResult Add(Web_AddRole model, bool isRedirect = false)
        {
            ViewData.Model = model;

            var id = model.Id;
            model.UserId = userId;
            var role = MapperHelper.Map<App_Role>(model);

            app_roleService.AddOrUpdate(role, model.menuIds);
            if (!isRedirect)
            {
                if (id > 0)
                {
                    AddAlertMsg("修改成功");
                }
                else
                {
                    AddAlertMsg("添加成功");
                }
            }
            else
            {
                return RedirectToAction("Index");
            }

            return View(model);
        }
Beispiel #2
0
        public ActionResult Add(Web_AddRole model, bool isRedirect = false)
        {
            ViewData.Model = model;

            var id = model.Id;
            model.UserId = userId;
            var role = MapperHelper.Map<Sys_Role>(model);

            //為了防止出現管理員權限被刪除的情況,可能是程序bug,但是偶兒出現,不能重現,所以要求menuIds不能為空
            if (string.IsNullOrEmpty(model.menuIds) || model.menuIds.ConvertToList().Count == 0)
            {
                throw new MsgEx("請選擇一項菜單,如果不選擇菜單請刪除該角色");
            }
            sys_RoleService.AddOrUpdate(role, model.menuIds);
            if (!isRedirect)
            {
                if (id > 0)
                {
                    AddAlertMsg("修改成功");
                }
                else
                {
                    AddAlertMsg("添加成功");
                }
            }
            else
            {
                return RedirectToAction("Index");
            }

            return View(model);
        }