Index: branches/ClientManagement/HeuristicLab.Services.Authentication/HeuristicLab.Services.Authentication.AdminMethods/ClientAdmin.cs
===================================================================
--- branches/ClientManagement/HeuristicLab.Services.Authentication/HeuristicLab.Services.Authentication.AdminMethods/ClientAdmin.cs	(revision 4695)
+++ branches/ClientManagement/HeuristicLab.Services.Authentication/HeuristicLab.Services.Authentication.AdminMethods/ClientAdmin.cs	(revision 4695)
@@ -0,0 +1,171 @@
+﻿using System;
+using System.Collections.Generic;
+using System.Collections;
+using System.Linq;
+using System.Data.Linq;
+using System.Data.Linq.Mapping;
+using System.Text;
+
+using HeuristicLab.Services.Authentication.DataAccess;
+using HeuristicLab.Services.Authentication.DataTransfer;
+using HeuristicLab.Services.Authentication;
+using DA = HeuristicLab.Services.Authentication.DataAccess;
+using DT = HeuristicLab.Services.Authentication.DataTransfer;
+using HLSA = HeuristicLab.Services.Authentication;
+
+namespace HeuristicLab.Services.Authentication.AdminMethods {
+  public class ClientAdmin : ResourceAdmin {
+
+    private void TransferData(DT.Client c, Hashtable values) {
+      c.ResourceID = new Guid((string)values[eResource.ResourceID]);
+      c.Name = (string)values[eResource.Name];
+      c.Description = (string)values[eResource.Description];
+      c.ResourceType = "Client";
+      c.ProcessorType = (string)values[eResource.ProcessorType];
+      c.NumberOfProcessors = (string)values[eResource.NumberOfProcessors];
+      c.NumberOfThreads = (string)values[eResource.NumberOfThreads];
+      c.MemorySize = (string)values[eResource.MemorySize];
+      c.IPAdress = (string)values[eResource.IPAdress];
+      c.OperatingSystem = (string)values[eResource.OperatingSystem];
+    }
+
+    public override HashSet<Hashtable> Get(Hashtable values) {
+      values[eResource.ResourceType] = "Client";
+      String QueryString = "SELECT * FROM Resource";
+      List<String> lcv = new List<String>();
+      String QueryStringExtension = " WHERE ";
+      CreateQueryStringExtension(lcv, ref QueryStringExtension, values);
+      if (QueryStringExtension.CompareTo(" WHERE ") > 0) {
+        QueryString += QueryStringExtension;
+      } // else select all
+      //string val1 = "%" + ((string)tmpHt[eClient.Name]) + "%";
+      //QueryString += eClient.Name + " LIKE {0}";
+      object[] compValues = lcv.ToArray();
+      using (ClientManagmentDataContext cmdc = new ClientManagmentDataContext()) {
+        if (cmdc.DatabaseExists()) {
+          Table<DA.Resource> clTable = cmdc.GetTable<DA.Resource>();
+          IEnumerable<DA.Resource> clients = cmdc.ExecuteQuery<DA.Resource>(QueryString, compValues);
+          HashSet<Hashtable> resultSet = new HashSet<Hashtable>();
+          var selectedClients = from c in clients orderby c.Name select HLSA.Convert.ToDto((DA.Client)c);
+          foreach (DT.Client cl in selectedClients) {
+            Hashtable ht = new Hashtable();
+            ht.Add(eResource.ResourceID, cl.ResourceID);
+            ht.Add(eResource.Name, cl.Name);
+            ht.Add(eResource.Description, cl.Description);
+            ht.Add(eResource.ResourceType, cl.ResourceType);
+            ht.Add(eResource.ProcessorType, cl.ProcessorType);
+            ht.Add(eResource.NumberOfProcessors, cl.NumberOfProcessors);
+            ht.Add(eResource.NumberOfThreads, cl.NumberOfThreads);
+            ht.Add(eResource.IPAdress, cl.IPAdress);
+            ht.Add(eResource.MemorySize, cl.MemorySize);
+            ht.Add(eResource.OperatingSystem, cl.OperatingSystem);
+            // look for group entries in ResourceResourcGroup  
+            //Guid groupID = new Guid();  /// ??
+            String groupID = "";
+            String groupName = "";
+            GetGroupIDandName(ref groupID, ref groupName, cmdc, cl.ResourceID);
+            ht.Add(eResource.ResourceIDGroup, groupID);
+            ht.Add(eResource.ResourceNameGroup, groupName);
+
+            resultSet.Add(ht);
+          }
+          return resultSet;
+        }
+        return null;
+      }
+    }
+    
+    public override bool Create(Hashtable values) {
+      if (((string)values[eResource.ResourceIDGroup] == "") ||
+          ((string)values[eResource.ResourceID] != "")) {
+        return false;
+      }
+      DT.Client c = new DT.Client();
+      values[eResource.ResourceID] = Guid.NewGuid().ToString();
+      values[eResource.ResourceType] = "Client";
+      TransferData(c, values);
+      Guid groupID = new Guid((string)values[eResource.ResourceIDGroup]);
+      using (ClientManagmentDataContext cmdc = new ClientManagmentDataContext()) {
+        if (cmdc.DatabaseExists()) {
+          // Client
+          DA.Client clEntity = HLSA.Convert.ToEntity(c);
+          cmdc.GetTable<DA.Resource>().InsertOnSubmit(clEntity);
+
+          Table<DA.Resource> clTable = cmdc.GetTable<DA.Resource>();
+          //Table<ResourceResourceGroup> rrgTable = cmdc.GetTable<ResourceResourceGroup>();
+          DA.Resource groupEntity = cmdc.GetTable<DA.Resource>().FirstOrDefault(x => x.ResourceID == groupID);
+          if (groupEntity == null)
+            return false;
+
+          cmdc.SubmitChanges();
+
+          DA.Resource clientEntity = cmdc.GetTable<DA.Resource>().FirstOrDefault(x => x.ResourceID == c.ResourceID);
+          if (clientEntity == null)
+           return false;
+
+          //ResourceResourceGroup 
+          ResourceResourceGroup rrgEntity = new ResourceResourceGroup();
+          rrgEntity.ResourceGroupID = groupEntity.ResourceID;
+          rrgEntity.ResourceID = clientEntity.ResourceID;
+          cmdc.GetTable<ResourceResourceGroup>().InsertOnSubmit(rrgEntity);
+
+          cmdc.SubmitChanges();
+          return true;
+        }
+        return false;
+      }
+    }
+
+    public override bool Update(Hashtable values) {
+      string groupIDString = (string)values[eResource.ResourceIDGroup];
+      string IDString = (string)values[eResource.ResourceID];
+
+      DT.Client uc = new DT.Client();
+      bool groupModified = false;
+      bool success = true;
+      bool validGroupID = (IDString != "") && (IsIDString(groupIDString));
+      bool validID = (IDString != "") && (IsIDString(IDString));
+
+      if (!validGroupID || !validID || (IDString.CompareTo(groupIDString) == 0))
+        return false;
+
+      Guid resID = new Guid(IDString);
+      TransferData(uc, values);
+
+      using (ClientManagmentDataContext cmdc = new ClientManagmentDataContext()) {
+
+        if (cmdc.DatabaseExists()) {
+            Guid currentGroupID = new Guid(groupIDString);
+            Guid oldGroupID = new Guid();
+
+            ResourceResourceGroup rrgEntity = cmdc.GetTable<ResourceResourceGroup>().FirstOrDefault(
+                                 x => x.ResourceID == resID);
+          if (rrgEntity != null) {
+            oldGroupID = rrgEntity.ResourceGroupID;
+          }
+          // check if groupname was modified
+          groupModified = (oldGroupID != currentGroupID);
+
+          DA.Resource clientEntity = cmdc.GetTable<DA.Resource>().FirstOrDefault(x => x.ResourceID == uc.ResourceID);
+          // update client
+          if ((clientEntity != null) && success) {
+            uc.ResourceType = clientEntity.ResourceType; // dont allow change of ResourceTyp
+            HLSA.Convert.ToEntity(uc, (DA.Client)clientEntity);
+            if (groupModified) {
+              // remove entry in ResourceResourcGroup if group modiied
+              RemoveRRGEntry(cmdc, resID);
+            }
+            cmdc.SubmitChanges();
+          }
+
+          if (groupModified && success) {
+            CreateRRGEntry(cmdc, resID, currentGroupID);
+            cmdc.SubmitChanges();
+          }
+        }
+      }
+      return success;
+    }    
+
+  }
+}
Index: branches/ClientManagement/HeuristicLab.Services.Authentication/HeuristicLab.Services.Authentication.AdminMethods/GroupAdmin.cs
===================================================================
--- branches/ClientManagement/HeuristicLab.Services.Authentication/HeuristicLab.Services.Authentication.AdminMethods/GroupAdmin.cs	(revision 4695)
+++ branches/ClientManagement/HeuristicLab.Services.Authentication/HeuristicLab.Services.Authentication.AdminMethods/GroupAdmin.cs	(revision 4695)
@@ -0,0 +1,160 @@
+﻿using System;
+using System.Collections.Generic;
+using System.Collections;
+using System.Linq;
+using System.Data.Linq;
+using System.Data.Linq.Mapping;
+using System.Text;
+
+using HeuristicLab.Services.Authentication.DataAccess;
+using HeuristicLab.Services.Authentication.DataTransfer;
+using HeuristicLab.Services.Authentication;
+using DA = HeuristicLab.Services.Authentication.DataAccess;
+using DT = HeuristicLab.Services.Authentication.DataTransfer;
+using HLSA = HeuristicLab.Services.Authentication;
+
+namespace HeuristicLab.Services.Authentication.AdminMethods {
+  public class GroupAdmin : ResourceAdmin {
+
+    public override HashSet<Hashtable> Get(Hashtable values) {
+      values[eResource.ResourceType] = "ResourceGroup";
+      String QueryString = "SELECT * FROM Resource";
+      List<String> lcv = new List<String>();
+      String QueryStringExtension = " WHERE ";
+      CreateQueryStringExtension(lcv, ref QueryStringExtension, values);
+      if (QueryStringExtension.CompareTo(" WHERE ") > 0) {
+        QueryString += QueryStringExtension;
+      } // else select all
+      object[] compValues = lcv.ToArray();
+      using (ClientManagmentDataContext cmdc = new ClientManagmentDataContext()) {
+        if (cmdc.DatabaseExists()) {
+          Table<DA.Resource> clTable = cmdc.GetTable<DA.Resource>();
+          IEnumerable<DA.Resource> groups = cmdc.ExecuteQuery<DA.Resource>(QueryString, compValues);
+          HashSet<Hashtable> resultSet = new HashSet<Hashtable>();
+          var selectedGroups = from c in groups orderby c.Name select HLSA.Convert.ToDto((DA.ResourceGroup)c);
+          foreach (DT.ResourceGroup cl in selectedGroups) {
+            Hashtable ht = new Hashtable();
+            ht.Add(eResource.ResourceID, cl.ResourceID);
+            ht.Add(eResource.Name, cl.Name);
+            ht.Add(eResource.Description, cl.Description);
+            ht.Add(eResource.ResourceType, cl.ResourceType);
+            // look for group entries in ResourceResourcGroup  
+            //Guid groupID = new Guid();  /// ??
+            String groupID = "";
+            String groupName = "";
+            GetGroupIDandName(ref groupID, ref groupName, cmdc, cl.ResourceID);
+
+            ht.Add(eResource.ResourceIDGroup, groupID);
+            ht.Add(eResource.ResourceNameGroup, groupName);
+
+            resultSet.Add(ht);
+          }
+          return resultSet;
+        }
+        return null;
+      }
+    }
+
+    private void TransferData(DT.ResourceGroup c, Hashtable values) {
+      c.ResourceID = new Guid((string)values[eResource.ResourceID]);
+      c.Name = (string)values[eResource.Name];
+      c.Description = (string)values[eResource.Description];
+      c.ResourceType = "ResourceGroup";
+    }
+
+    public override bool Create(Hashtable values) {
+      if ((values[eResource.ResourceID] != null) && ((string)values[eResource.ResourceID] != "")) {
+        return false;
+      }
+      DT.ResourceGroup g = new DT.ResourceGroup();
+      values[eResource.ResourceID] = Guid.NewGuid().ToString();
+      TransferData(g, values);
+
+      using (ClientManagmentDataContext cmdc = new ClientManagmentDataContext()) {
+        if (cmdc.DatabaseExists()) {
+          DA.ResourceGroup gEntity = HLSA.Convert.ToEntity(g);
+          cmdc.GetTable<DA.Resource>().InsertOnSubmit(gEntity);
+          cmdc.SubmitChanges();
+
+          //ResourceResourceGroup 
+          if ((values[eResource.ResourceIDGroup] != null) && ((string)values[eResource.ResourceIDGroup] != "")) {
+            Guid groupID = new Guid((string)values[eResource.ResourceIDGroup]);
+
+            Table<DA.Resource> clTable = cmdc.GetTable<DA.Resource>();
+            Table<ResourceResourceGroup> rrgTable = cmdc.GetTable<ResourceResourceGroup>();
+            DA.Resource groupEntity = cmdc.GetTable<DA.Resource>().FirstOrDefault(x => x.ResourceID == groupID);
+            if (groupEntity == null)
+              return false;
+
+            cmdc.SubmitChanges();
+
+            DA.Resource clientEntity = cmdc.GetTable<DA.Resource>().FirstOrDefault(x => x.ResourceID == g.ResourceID);
+            if (clientEntity == null)
+              return false;
+
+            //ResourceResourceGroup 
+            ResourceResourceGroup rrgEntity = new ResourceResourceGroup();
+            rrgEntity.ResourceGroupID = groupEntity.ResourceID;
+            rrgEntity.ResourceID = clientEntity.ResourceID;
+            cmdc.GetTable<ResourceResourceGroup>().InsertOnSubmit(rrgEntity);
+
+            cmdc.SubmitChanges();
+          }
+          return true;
+        }
+        return false;
+      }
+    }
+
+    public override bool Update(Hashtable values) {
+      string groupIDString = (string)values[eResource.ResourceIDGroup];
+      string IDString = (string)values[eResource.ResourceID];
+
+      DT.ResourceGroup uc = new DT.ResourceGroup();
+      bool groupModified = false;
+      bool success = true;
+      bool validGroupID = IsIDString(groupIDString);
+      bool validID = (IDString != "") && (IsIDString(IDString));
+
+      if (!validGroupID || !validID || (IDString.CompareTo(groupIDString) == 0))
+        return false;
+
+      Guid resID = new Guid(IDString);
+      TransferData(uc, values);
+
+      using (ClientManagmentDataContext cmdc = new ClientManagmentDataContext()) {
+
+        if (cmdc.DatabaseExists()) {
+          Guid currentGroupID = new Guid(groupIDString);
+          Guid oldGroupID = new Guid();
+
+          ResourceResourceGroup rrgEntity = cmdc.GetTable<ResourceResourceGroup>().FirstOrDefault(
+                               x => x.ResourceID == resID);
+          
+          if (rrgEntity != null) {
+            oldGroupID = rrgEntity.ResourceGroupID;
+          }
+          // check if groupname was modified
+          groupModified = (oldGroupID != currentGroupID);
+          DA.Resource resEntity = cmdc.GetTable<DA.Resource>().FirstOrDefault(x => x.ResourceID == uc.ResourceID);
+          // update client
+          if ((resEntity != null) && success) {
+            uc.ResourceType = resEntity.ResourceType; // dont allow change of ResourceTyp
+            HLSA.Convert.ToEntity(uc, (DA.ResourceGroup)resEntity);
+            if (groupModified) {
+              // remove entry in ResourceResourcGroup if group modiied
+              RemoveRRGEntry(cmdc, resID);              
+            }
+            cmdc.SubmitChanges();
+          }
+
+          if (groupModified && success) {
+            CreateRRGEntry(cmdc, resID, currentGroupID);
+            cmdc.SubmitChanges();
+          }
+        }
+      }
+      return success;
+    }
+  }
+}
Index: branches/ClientManagement/HeuristicLab.Services.Authentication/HeuristicLab.Services.Authentication.AdminMethods/HeuristicLab.Services.Authentication.AdminMethods.csproj
===================================================================
--- branches/ClientManagement/HeuristicLab.Services.Authentication/HeuristicLab.Services.Authentication.AdminMethods/HeuristicLab.Services.Authentication.AdminMethods.csproj	(revision 4695)
+++ branches/ClientManagement/HeuristicLab.Services.Authentication/HeuristicLab.Services.Authentication.AdminMethods/HeuristicLab.Services.Authentication.AdminMethods.csproj	(revision 4695)
@@ -0,0 +1,87 @@
+﻿<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
+    <ProductVersion>8.0.30703</ProductVersion>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{2DC20235-6A91-4ABC-8E3E-660B43EAD23B}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>HeuristicLab.Services.Authentication.AdminMethods</RootNamespace>
+    <AssemblyName>HeuristicLab.Services.Authentication.AdminMethods</AssemblyName>
+    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+    <TargetFrameworkProfile>Client</TargetFrameworkProfile>
+    <FileAlignment>512</FileAlignment>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
+    <PlatformTarget>x86</PlatformTarget>
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
+    <PlatformTarget>x86</PlatformTarget>
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup>
+    <SignAssembly>true</SignAssembly>
+  </PropertyGroup>
+  <PropertyGroup>
+    <AssemblyOriginatorKeyFile>HLAuthenticationAdminMethods.pfx</AssemblyOriginatorKeyFile>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="System" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Data.Linq" />
+    <Reference Include="System.Drawing" />
+    <Reference Include="System.Windows.Forms" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="AdminMethods.cs" />
+    <Compile Include="ClientAdmin.cs" />
+    <Compile Include="GroupAdmin.cs" />
+    <Compile Include="Program.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="ResourceAdmin.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\HeuristicLab.Services.Authentication.DataAccess\HeuristicLab.Services.Authentication.DataAccess.csproj">
+      <Project>{AC7C2117-034E-4301-8A43-C869930D404E}</Project>
+      <Name>HeuristicLab.Services.Authentication.DataAccess</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\HeuristicLab.Services.Authentication.DataTransfer\HeuristicLab.Services.Authentication.DataTransfer.csproj">
+      <Project>{73E5113E-A293-4384-8B16-3CE38F2CFDC9}</Project>
+      <Name>HeuristicLab.Services.Authentication.DataTransfer</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\HeuristicLab.Services.Authentication\HeuristicLab.Services.Authentication.csproj">
+      <Project>{ED8DC6E8-57C6-49E0-8CDF-25703AC52350}</Project>
+      <Name>HeuristicLab.Services.Authentication</Name>
+    </ProjectReference>
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="HLAuthenticationAdminMethods.pfx" />
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>
Index: branches/ClientManagement/HeuristicLab.Services.Authentication/HeuristicLab.Services.Authentication.AdminMethods/Properties/AssemblyInfo.cs
===================================================================
--- branches/ClientManagement/HeuristicLab.Services.Authentication/HeuristicLab.Services.Authentication.AdminMethods/Properties/AssemblyInfo.cs	(revision 4695)
+++ branches/ClientManagement/HeuristicLab.Services.Authentication/HeuristicLab.Services.Authentication.AdminMethods/Properties/AssemblyInfo.cs	(revision 4695)
@@ -0,0 +1,36 @@
+﻿using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following 
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("HeuristicLab.Services.Authentication.AdminMethods")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("HeuristicLab.Services.Authentication.AdminMethods")]
+[assembly: AssemblyCopyright("Copyright ©  2010")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible 
+// to COM components.  If you need to access a type in this assembly from 
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("cd5eaa9a-2caf-4989-bf5f-a76b2006cb8b")]
+
+// Version information for an assembly consists of the following four values:
+//
+//      Major Version
+//      Minor Version 
+//      Build Number
+//      Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers 
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
Index: branches/ClientManagement/HeuristicLab.Services.Authentication/HeuristicLab.Services.Authentication.AdminMethods/ResourceAdmin.cs
===================================================================
--- branches/ClientManagement/HeuristicLab.Services.Authentication/HeuristicLab.Services.Authentication.AdminMethods/ResourceAdmin.cs	(revision 4695)
+++ branches/ClientManagement/HeuristicLab.Services.Authentication/HeuristicLab.Services.Authentication.AdminMethods/ResourceAdmin.cs	(revision 4695)
@@ -0,0 +1,115 @@
+﻿using System;
+using System.Collections.Generic;
+using System.Collections;
+using System.Linq;
+using System.Data.Linq;
+using System.Data.Linq.Mapping;
+using System.Text;
+
+using HeuristicLab.Services.Authentication.DataAccess;
+using HeuristicLab.Services.Authentication.DataTransfer;
+using HeuristicLab.Services.Authentication;
+using DA = HeuristicLab.Services.Authentication.DataAccess;
+using DT = HeuristicLab.Services.Authentication.DataTransfer;
+using HLSA = HeuristicLab.Services.Authentication;
+
+namespace HeuristicLab.Services.Authentication.AdminMethods {
+
+  public enum eResource {
+    ResourceID = 1, Name = 2, Description = 3, ResourceType = 4,
+    ProcessorType = 5, NumberOfProcessors = 6, NumberOfThreads = 7,
+    MemorySize = 8, IPAdress = 9, OperatingSystem = 10, ResourceNameGroup, ResourceIDGroup,
+    GroupGroupID, GroupGroupName
+  };
+
+  public abstract class ResourceAdmin {    
+
+    public abstract HashSet<Hashtable> Get(Hashtable values);
+    public abstract bool Create(Hashtable values);    
+    public abstract bool Update(Hashtable values);    
+    
+    public bool RemoveRRGEntry(ClientManagmentDataContext cmdc, Guid resID) {
+      ResourceResourceGroup rrgEntity = cmdc.GetTable<ResourceResourceGroup>().FirstOrDefault(
+                      x => x.ResourceID == resID);
+      //ResourceResourceGroup rrgEntityGroup = cmdc.GetTable<ResourceResourceGroup>().FirstOrDefault(
+      //                x => x.ResourceGroupID == resID);
+      if (rrgEntity != null) { // && (rrgEntityGroup == null)) {
+        cmdc.GetTable<ResourceResourceGroup>().DeleteOnSubmit(rrgEntity);
+        return true;
+      }
+      return false;
+    }
+    
+    public void CreateRRGEntry(ClientManagmentDataContext cmdc, Guid clientID, Guid groupID) {
+      ResourceResourceGroup rrgEntity = new ResourceResourceGroup();
+      rrgEntity.ResourceGroupID = groupID;
+      rrgEntity.ResourceID = clientID;
+      cmdc.GetTable<ResourceResourceGroup>().InsertOnSubmit(rrgEntity);
+    }
+    
+    public void GetGroupIDandName(ref String groupID, ref String groupName, ClientManagmentDataContext cmdc, Guid clientID) {
+      ResourceResourceGroup rrgEntity = cmdc.GetTable<ResourceResourceGroup>().FirstOrDefault(
+                               x => x.ResourceID == clientID);
+      if (rrgEntity != null) {
+        groupID = (rrgEntity.ResourceGroupID).ToString();
+        DA.Resource groupEntity = cmdc.GetTable<DA.Resource>().FirstOrDefault(
+                  x => x.ResourceID == rrgEntity.ResourceGroupID);
+        groupName = groupEntity.Name;
+      }
+    }
+    
+    public void CreateQueryStringExtension(List<String> compareValues, ref String QueryStringExtension, Hashtable ht) {
+      int i = 0;
+      foreach (DictionaryEntry kvp in ht) {
+        if (((string)kvp.Value != "") &&
+          (kvp.Key.Equals(eResource.ResourceNameGroup) == false) &&
+          (kvp.Key.Equals(eResource.ResourceIDGroup) == false)) {
+          compareValues.Add(String.Format("%" + (ht[kvp.Key]).ToString() + "%"));
+          if (i == 0)
+            QueryStringExtension += (kvp.Key.ToString() + " LIKE {" + i + "}");
+          else
+            QueryStringExtension += " AND " + (kvp.Key.ToString() + " LIKE {" + i + "}");
+          i++;
+        }
+      }
+    }
+    
+    public bool Delete(Hashtable values) {
+      string idStr = (string)values[eResource.ResourceID];
+      if ((idStr == "") || (!IsIDString(idStr))) {
+        return false;
+      }
+
+      using (ClientManagmentDataContext cmdc = new ClientManagmentDataContext()) {
+        Guid clientID = new Guid(idStr);
+
+        if (cmdc.DatabaseExists()) {
+          // remove entry in ResourceResourcGroup  
+          //if (!(RemoveRRGEntry(cmdc, clientID)))
+          //  return false;
+          RemoveRRGEntry(cmdc, clientID);
+          // check if resource is member of a group
+          DA.Resource Entity = cmdc.GetTable<DA.Resource>().FirstOrDefault(x => x.ResourceID == new Guid(idStr));
+          
+          // only allow removing if group is not still in use
+          DA.ResourceResourceGroup rrgEntity = cmdc.GetTable<DA.ResourceResourceGroup>()
+                              .FirstOrDefault(x => x.ResourceGroupID == new Guid(idStr));
+          if ((Entity != null) && (rrgEntity == null)) {
+            cmdc.GetTable<DA.Resource>().DeleteOnSubmit(Entity);
+            cmdc.SubmitChanges();
+            return true;
+          }
+        }
+      } return false;
+    }
+
+    public bool IsIDString (string idString){
+      try{
+        Guid gid = new Guid(idString);
+        return true;
+      }
+      catch (Exception e) {return false;}
+    }
+
+  }
+}
