Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/26/10 13:11:44 (14 years ago)
Author:
mholper
Message:

formated with vssettings, added missing .Dispose() to following HeuristicLabRoleProvider Methods: GetAllRolesTest, IsUserInRole, CreateRole,GetAllRoles (#1046)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Services.Authentication Prototype/Service/Provider/HeuristicLabRoleProvider.cs

    r3963 r3964  
    2424        }
    2525        db.SubmitChanges();
     26        db.Dispose();
    2627      }
    2728    }
     
    4950        db.HeuristicLabRole.InsertOnSubmit(role);
    5051        db.SubmitChanges();
     52        db.Dispose();
    5153      }
    5254    }
     
    7476      List<string> roleList = new List<string>();
    7577
    76       List<HeuristicLabRole> roles = new List<HeuristicLabRole>(DatabaseUtil.createDataClassesDataContext().HeuristicLabRole.Select(r => r));
     78      Persistence.DataClassesDataContext db = DatabaseUtil.createDataClassesDataContext();
     79      List<HeuristicLabRole> roles = new List<HeuristicLabRole>(db.HeuristicLabRole.Select(r => r));
    7780      foreach (HeuristicLabRole r in roles) {
    7881        roleList.Add(r.RoleName);
    7982      }
     83      db.Dispose();
    8084
    8185      return roleList.ToArray();
     
    100104    }
    101105
    102 
    103     /// <summary>
    104     /// true if given username has exists in given Role, else false
    105     /// </summary>
    106     /// <param name="username"></param>
    107     /// <param name="roleName"></param>
    108     /// <returns>bool</returns>
    109106    public override bool IsUserInRole(string username, string roleName) {
    110         bool returnValue = false;
    111         DataClassesDataContext context = DatabaseUtil.createDataClassesDataContext();
    112         if (username != null && roleName != null)
    113         {
    114             returnValue = (context.HeuristicLabUserRole.Count(ur => ur.HeuristicLabRole.RoleName == roleName && ur.HeuristicLabUser.UserName == username) > 0);
    115         }
    116         return returnValue;
     107      bool returnValue = false;
     108      DataClassesDataContext context = DatabaseUtil.createDataClassesDataContext();
     109      if (username != null && roleName != null) {
     110        returnValue = (context.HeuristicLabUserRole.Count(ur => ur.HeuristicLabRole.RoleName == roleName && ur.HeuristicLabUser.UserName == username) > 0);
     111      }
     112      context.Dispose();
     113      return returnValue;
    117114    }
    118115
Note: See TracChangeset for help on using the changeset viewer.