Exemplo n.º 1
0
 public async Task<int> UpdatePermissionGrants(UpdatePermissionGrantsInput input)
 {
     foreach (PermissionGrant permissionGrant in input.AllowGrants)
     {
         permissionGrant.Type = 1;
         permissionGrant.PermissionId = input.PermissionId;
         if (permissionGrant.IsExactPattern)
         {
             permissionGrant.TermPattern = null;
         }
         else
         {
             permissionGrant.TermExactPattern = null;
             permissionGrant.TermPattern = permissionGrant.TermPattern == "*" ? ".*" : permissionGrant.TermPattern;
         }
     }
     foreach (PermissionGrant permissionGrant in input.DenyGrants)
     {
         permissionGrant.Type = 0;
         permissionGrant.PermissionId = input.PermissionId;
         if (permissionGrant.IsExactPattern)
             permissionGrant.TermPattern = null;
         else
             permissionGrant.TermExactPattern = null;
     }
     PermissionGrant[] permissionGrants = input.AllowGrants.Concat(input.DenyGrants).Where(m =>
                                                                                                      {
                                                                                                          if (m.IsExactPattern && !string.IsNullOrEmpty(m.TermExactPattern))
                                                                                                              return true;
                                                                                                          if (!m.IsExactPattern)
                                                                                                              return !string.IsNullOrEmpty(m.TermPattern);
                                                                                                          return false;
                                                                                                      }).ToArray();
     int result = _permissionTable.UpdatePermissionGrants(input.PermissionId, permissionGrants);
     int num = await GenerateRolesForUserByPermission(input.PermissionId);
     return result;
 }
 public async Task<ResultUpdateOutput> UpdatePermissionGrants(UpdatePermissionGrantsInput input)
 {
     var result = new ResultUpdateOutput
                  {
         Status = 1
     };
     int test = await _permissionBll.UpdatePermissionGrants(input);
     if (test > 0)
         result.Status = 0;
     return result;
 }