public void Insert(IUserType userType, IContent node, char permissionKey) { // Method is synchronized so exists remains consistent (avoiding race condition) bool exists = _sqlHelper.Fetch <int>("SELECT UserTypeId FROM UserTypePermissions WHERE UserTypeId = @0 AND NodeId = @1 AND PermissionId = @2", userType.Id, node.Id, permissionKey.ToString()).Any(); if (!exists) { var newPerms = new UserTypePermissionRow { NodeId = node.Id, PermissionId = permissionKey.ToString(), UserTypeId = userType.Id, }; _sqlHelper.Insert(newPerms); } }
public void Insert(IUserType userType, IContent node, char permissionKey) { // Method is synchronized so exists remains consistent (avoiding race condition) bool exists = _sqlHelper.Fetch<int>("SELECT UserTypeId FROM UserTypePermissions WHERE UserTypeId = @0 AND NodeId = @1 AND PermissionId = @2", userType.Id, node.Id, permissionKey.ToString()).Any(); if (!exists) { var newPerms = new UserTypePermissionRow { NodeId = node.Id, PermissionId = permissionKey.ToString(), UserTypeId = userType.Id, }; _sqlHelper.Insert(newPerms); } }