示例#1
0
        public ApiMessage CreateRole()
        {
            ApiMessage message = new ApiMessage() { Status = "ok" };
            List<BAdminRole> roles = new List<BAdminRole>();
            HttpContextBase context = (HttpContextBase)Request.Properties["MS_HttpContext"];
            HttpRequestBase request = context.Request;
            string user_id = User.Identity.Name;
            UserManager userMgr = new UserManager(int.Parse(user_id), null);
            BUser user = userMgr.CurrentUser;
            PermissionManagement permissionMgt = new PermissionManagement(userMgr.CurrentUser, userMgr.Shop, userMgr.CurrentUserPermission);
            string role_name = request["role"];
            string desc=request["desc"];
            int shop_id = 0;
            int.TryParse(request["shop_id"],out shop_id);
            try
            {
                int[] actions = this.ConvertToIntArrar(request["actions"]);
                if (string.IsNullOrEmpty(role_name))
                {
                    message.Status = "failed";
                    message.Message = "分组名字不能为空";
                    return message;
                }
                BAdminRole role=permissionMgt.CreateRole(role_name, desc,actions, shop_id);
                message.Item = role;

            }
            catch (KMJXCException kex)
            {
                message.Status = "failed";
                message.Message = kex.Message;
            }
            catch
            {
            }
            finally
            {

            }
            return message;
        }