Esempio n. 1
0
 public bool Authorize(RoleMenuModel model)
 {
     try
     {
         var isDel = dal.DelRoleMenuButtonByRoleId(model.RoleId);
         if (isDel)
         {
             if (model.MenuButtonIds != null)
             {
                 foreach (var item in model.MenuButtonIds)
                 {
                     var roleMenuButton = new RoleMenuButton
                     {
                         Id       = Guid.NewGuid(),
                         RoleId   = model.RoleId,
                         ButtonId = item.buttonid,
                         MenuId   = item.menuid
                     };
                     var roleMenuButtons = dal.Authorize(roleMenuButton);
                     if (roleMenuButtons == null)
                     {
                         throw new Exception("循环添加出现程序错误,请联系管理员!");
                     }
                 }
             }
         }
         else
         {
             return(false);
         }
         return(true);
     }
     catch (Exception)
     {
         throw new Exception("出现程序错误,请联系管理员!");
     }
 }