Exemplo n.º 1
0
        public ActionResult AddMenu(int id, string menuIds)
        {
            ControllerResult result = ControllerResult.SuccResult;

            try
            {
                // TODO: Add update logic here
                string     errorMsg  = string.Empty;
                List <int> pathIds   = new List <int>();
                bool       addResult = true;
                if (menuIds.IsNullOrEmpty())
                {
                    addResult = roleService.AddPathsIntoRole(pathIds, id, out errorMsg);
                }
                else
                {
                    foreach (var item in menuIds.Split(','))
                    {
                        pathIds.Add(int.Parse(item));
                    }
                    addResult = roleService.AddPathsIntoRole(pathIds, id, out errorMsg);
                }
                if (!addResult)
                {
                    result.IsSucc  = addResult;
                    result.ErroMsg = errorMsg;
                }
                else
                {
                    LogUserAction("对id为{0}进行角色模块设置操作".Fmt(id));
                }
            }
            catch (Exception ex)
            {
                result         = ControllerResult.FailResult;
                result.ErroMsg = ex.Message;
            }

            return(Content(result.ToJson()));
        }