Index: branches/WebApplication/MVC2/HLWebOKBAdminPlugin/Models/AlgorithmClassModel.cs
===================================================================
--- branches/WebApplication/MVC2/HLWebOKBAdminPlugin/Models/AlgorithmClassModel.cs	(revision 6142)
+++ branches/WebApplication/MVC2/HLWebOKBAdminPlugin/Models/AlgorithmClassModel.cs	(revision 6143)
@@ -6,51 +6,68 @@
 using System.Web.Security;
 using HLWebOKBAdminPlugin.OKBAdministrationService;
+using HLWebOKBAdminPlugin.Helpers;
 
 namespace HLWebPluginHost.Models {
-    public class AlgorithmClassModel {
+    public class AlgorithmClassModel {        
 
-        private AdministrationServiceClient CertificateValidator() {
-            AdministrationServiceClient asc = new AdministrationServiceClient();
+        public String SelectedSubMenu { get; set; }
+        public IList<AlgorithmClass> AlgorithmClasses { get { return AlgorithmClassGetAll(); } }
 
-            asc.ClientCredentials.UserName.UserName = Membership.GetUser().UserName;
-            asc.ClientCredentials.UserName.Password = HttpContext.Current.Session["pwd"].ToString();
-            asc.ClientCredentials.ServiceCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.None;
 
-            return asc;
-        }//CertificateValidator
+        //***************************************Algorithm Class********************************************
+        //get all algorithm classes
+        private IList<AlgorithmClass> AlgorithmClassGetAll() {
+            AdministrationServiceClient adminClient = Admin.GetClientFactory();
 
-        public int NumOfClasses { get; set; }
-        public List<AlgorithmClass> AlgorithmClassList { get; set; }
+            IList<AlgorithmClass>  algorithmClassList = new List<AlgorithmClass>();
 
-        public List<AlgorithmClass> AlgorithmClassGetAll() {
-            //returns list of algorithm classes            
-            AdministrationServiceClient asc = CertificateValidator();
+            if (adminClient != null) {
+                AlgorithmClass[] algorithmClasses = adminClient.GetAlgorithmClasses();
+                foreach (AlgorithmClass ac in algorithmClasses) {
+                    algorithmClassList.Add(ac);
 
-            var agcList = new List<AlgorithmClass>();
+                }
+            }//if (adminClient != null)
 
-            AlgorithmClass[] ac = asc.GetAlgorithmClasses();
-            foreach (AlgorithmClass a in ac) {
-                agcList.Add(a);
-
-            }//foreach
-
-            return agcList;
+            return algorithmClassList;
         }//AlgorithmClassGetAll
 
-        //Add AlgorithmClass table entry
-        public bool AddAlgorithmClass(string name, string description) {
-            long retValue;
-            //get service client
-            AdministrationServiceClient asc = CertificateValidator();
+        private long AddAlgorithmClass(AlgorithmClass algorithmClass) {
+            AdministrationServiceClient adminClient = Admin.GetClientFactory();
 
-            AlgorithmClass ac = new AlgorithmClass();
-            //test
-            //ac.Id = 8;
-            ac.Name = name;
-            ac.Description = description;
-            retValue = asc.AddAlgorithmClass(ac);
-            
-            return true;
+            if (adminClient != null) {
+                return adminClient.AddAlgorithmClass(algorithmClass);
+            }
+
+            return 0;
         }//AddAlgorithmClass
+
+        public void DeleteAlgorithmClass(long id) {
+            AdministrationServiceClient adminClient = Admin.GetClientFactory();
+
+            if (adminClient != null) {
+                adminClient.DeleteAlgorithmClass(id);
+            }
+        }//DeleteAlgorithmClass
+
+        public long SaveAlgorithmClass(AlgorithmClass algorithmClass) {
+            AdministrationServiceClient adminClient = Admin.GetClientFactory();
+
+            if (adminClient != null) {
+                if (algorithmClass.Id == 0) {
+                    return AddAlgorithmClass(algorithmClass);
+                }
+                else {
+                    AlgorithmClass ac = adminClient.GetAlgorithmClass(algorithmClass.Id);
+
+                    if (ac != null) {
+                        adminClient.UpdateAlgorithmClass(algorithmClass);
+                        return algorithmClass.Id;
+                    }
+                }
+            }
+
+            return 0;
+        }//SaveAlgorithmClass               
     }
 }
