Index: branches/WebApplication/MVC2/HLWebOKBAdminPlugin/Models/ProblemModel.cs
===================================================================
--- branches/WebApplication/MVC2/HLWebOKBAdminPlugin/Models/ProblemModel.cs	(revision 6153)
+++ branches/WebApplication/MVC2/HLWebOKBAdminPlugin/Models/ProblemModel.cs	(revision 6160)
@@ -8,49 +8,101 @@
 namespace HLWebOKBAdminPlugin.Models
 {
-    public class ProblemModel
-    {
-        /// <summary>
-        /// Get all Problems.
-        /// </summary>
-        public List<Problem> Problems
-        {
-            get
-            {
-                AdministrationServiceClient adminClient = Admin.GetClientFactory("okbtester", "okbtester");
-                IList<Problem> problemList = new List<Problem>();
-                Problem[] problems = adminClient.GetProblems();
-                return problems.ToList<Problem>();
-            }
-        }
+    public class ProblemModel {
 
-        public List<ProblemClass> ProblemClasses {
-            get {
-                AdministrationServiceClient adminClient = Admin.GetClientFactory("okbtester", "okbtester");
-                IList<ProblemClass> problemClassList = new List<ProblemClass>();
-                ProblemClass[] problemClass = adminClient.GetProblemClasses();
-                return problemClass.ToList<ProblemClass>();
-            }
-        }
+        public String SelectedSubMenu { get; set; }
+        public IList<Problem> Problems { get { return ProblemsGetAll(); } set { ;} }
+        public IList<ProblemClass> ProblemClasses { get { return ProblemClassGetAll(); } }
+        public IList<Platform> Platforms { get { return PlatformsGetAll(); } }
 
-        public List<Platform> Plattforms {
-            get {
-                AdministrationServiceClient adminClient = Admin.GetClientFactory("okbtester", "okbtester");
-                IList<Platform> plattformList = new List<Platform>();
-                Platform[] plattforms = adminClient.GetPlatforms();
-                return plattforms.ToList<Platform>();
-            }
-        }
-
-        /// <summary>
-        /// Curretn Problem (for Detail)
-        /// </summary>
         public Problem Problem { get; set; }
 
-        public void SaveProblem(Problem problem) {
-            AdministrationServiceClient adminClient = Admin.GetClientFactory("okbtester", "okbtester");
-            adminClient.UpdateProblem(problem);
-        }
+        public ProblemModel() {
+            Problem = new Problem();
+        }//ProblemModel
 
+        //***************************************Problems***************************************************
+        private IList<Platform> PlatformsGetAll() {
+            AdministrationServiceClient adminClient = Admin.GetClientFactory();
 
+            IList<Platform> platformList = new List<Platform>();
+
+            if (adminClient != null) {
+                Platform[] platforms = adminClient.GetPlatforms();
+                foreach (Platform pl in platforms) {
+                    platformList.Add(pl);
+                }
+            }//if (adminClient != null)
+
+            return platformList;
+        }//ProblemClassGetAll
+
+        private IList<ProblemClass> ProblemClassGetAll() {
+            AdministrationServiceClient adminClient = Admin.GetClientFactory();
+
+            IList<ProblemClass> problemClassList = new List<ProblemClass>();
+
+            if (adminClient != null) {
+                ProblemClass[] problemClasses = adminClient.GetProblemClasses();
+                foreach (ProblemClass pc in problemClasses) {
+                    problemClassList.Add(pc);
+                }
+            }//if (adminClient != null)
+
+            return problemClassList;
+        }//ProblemClassGetAll
+
+        private IList<Problem> ProblemsGetAll() {
+            AdministrationServiceClient adminClient = Admin.GetClientFactory();
+
+            IList<Problem> problemList = new List<Problem>();
+
+            if (adminClient != null) {
+                Problem[] problem = adminClient.GetProblems();
+                foreach (Problem pr in problem) {
+                    problemList.Add(pr);
+
+                }
+            }//if (adminClient != null)
+
+            return problemList;
+        }//ProblemsGetAll
+
+        private long AddProblem(Problem problem) {
+            AdministrationServiceClient adminClient = Admin.GetClientFactory();
+
+            if (adminClient != null) {
+                return adminClient.AddProblem(problem);
+            }
+
+            return 0;
+        }//AddProblem
+
+        public void DeleteProblem(long id) {
+            AdministrationServiceClient adminClient = Admin.GetClientFactory();
+
+            if (adminClient != null) {
+                adminClient.DeleteProblem(id);
+            }
+        }//DeleteProblem
+
+        public long SaveProblem(Problem problem) {
+            AdministrationServiceClient adminClient = Admin.GetClientFactory();
+
+            if (adminClient != null) {
+                if (problem.Id == 0) {
+                    return AddProblem(problem);
+                }
+                else {
+                    Problem pr = adminClient.GetProblem(problem.Id);
+
+                    if (pr != null) {
+                        adminClient.UpdateProblem(problem);
+                        return problem.Id;
+                    }
+                }
+            }
+
+            return 0;
+        }//SaveProblem
     }
 }
