using System; using System.Collections.Generic; using System.Linq; using System.Web; using HLWebOKBAdminPlugin.OKBAdministrationService; using HLWebOKBAdminPlugin.Helpers; namespace HLWebOKBAdminPlugin.Models { public class ProblemModel { public String SelectedSubMenu { get; set; } public IList Problems { get { return ProblemsGetAll(); } set { ;} } public IList ProblemClasses { get { return ProblemClassGetAll(); } } public IList Platforms { get { return PlatformsGetAll(); } } public Problem Problem { get; set; } public ProblemModel() { Problem = new Problem(); }//ProblemModel //***************************************Problems*************************************************** 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 IList ProblemsGetAll() { AdministrationServiceClient adminClient = Admin.GetClientFactory(); IList problemList = new List(); 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 public void UpdateProblemData(long id, byte[] data) { AdministrationServiceClient adminClient = Admin.GetClientFactory(); if (adminClient != null) { adminClient.UpdateProblemData(id, data); } }//UpdateProblemData } }