using System; using System.Collections.Generic; using System.Linq; using System.Web; using HLWebOKBAdminPlugin.OKBAdministrationService; using HLWebOKBAdminPlugin.Helpers; namespace HLWebOKBAdminPlugin.Models { public class ProblemClassModel { public String SelectedSubMenu { get; set; } public IList ProblemClasses { get { return ProblemClassGetAll(); } set { ;} } public ProblemClass ProblemClass { get; set; } public ProblemClassModel() { ProblemClass = new ProblemClass(); }//ProblemClassModel //***************************************Problem Class********************************************** private IList PlatformsGetAll() { AdministrationServiceClient adminClient = Admin.GetClientFactory(); IList platformList = new List(); if (adminClient != null) { Platform[] platforms = adminClient.GetPlatforms(); foreach (Platform pl in platforms) { platformList.Add(pl); } }//if (adminClient != null) return platformList; }//ProblemClassGetAll private IList ProblemClassGetAll() { AdministrationServiceClient adminClient = Admin.GetClientFactory(); IList problemClassList = new List(); if (adminClient != null) { ProblemClass[] problemClasses = adminClient.GetProblemClasses(); foreach (ProblemClass pc in problemClasses) { problemClassList.Add(pc); } }//if (adminClient != null) return problemClassList; }//ProblemClassGetAll private long AddProblemClass(ProblemClass problemClass) { AdministrationServiceClient adminClient = Admin.GetClientFactory(); if (adminClient != null) { return adminClient.AddProblemClass(problemClass); } return 0; }//AddProblemClass public void DeleteProblemClass(long id) { AdministrationServiceClient adminClient = Admin.GetClientFactory(); if (adminClient != null) { adminClient.DeleteProblemClass(id); } }//DeleteProblemClass public long SaveProblemClass(ProblemClass problemClass) { AdministrationServiceClient adminClient = Admin.GetClientFactory(); if (adminClient != null) { if (problemClass.Id == 0) { return AddProblemClass(problemClass); } else { ProblemClass pc = adminClient.GetProblemClass(problemClass.Id); if (pc != null) { adminClient.UpdateProblemClass(problemClass); return problemClass.Id; } } } return 0; }//SaveProblemClass } }