Free cookie consent management tool by TermsFeed Policy Generator

source: branches/WebApplication/MVC2/HLWebOKBAdminPlugin/Models/ProblemModel.cs @ 10138

Last change on this file since 10138 was 6317, checked in by jwolfing, 14 years ago

#1433 code formatted

File size: 3.4 KB
RevLine 
[6130]1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Web;
5using HLWebOKBAdminPlugin.OKBAdministrationService;
6using HLWebOKBAdminPlugin.Helpers;
7
[6317]8namespace HLWebOKBAdminPlugin.Models {
9  public class ProblemModel {
[6130]10
[6317]11    public String SelectedSubMenu { get; set; }
12    public IList<Problem> Problems {
13      get { return ProblemsGetAll(); }
14      set { ;}
15    }
16    public IList<ProblemClass> ProblemClasses { get { return ProblemClassGetAll(); } }
17    public IList<Platform> Platforms { get { return PlatformsGetAll(); } }
[6160]18
[6317]19    public Problem Problem { get; set; }
[6160]20
[6317]21    public ProblemModel() {
22      Problem = new Problem();
23    }//ProblemModel
[6160]24
[6317]25    //***************************************Problems***************************************************
26    private IList<Platform> PlatformsGetAll() {
27      AdministrationServiceClient adminClient = Admin.GetClientFactory();
[6160]28
[6317]29      IList<Platform> platformList = new List<Platform>();
[6160]30
[6317]31      if (adminClient != null) {
32        Platform[] platforms = adminClient.GetPlatforms();
33        foreach (Platform pl in platforms) {
34          platformList.Add(pl);
35        }
36      }//if (adminClient != null)
[6160]37
[6317]38      return platformList;
39    }//ProblemClassGetAll
[6160]40
[6317]41    private IList<ProblemClass> ProblemClassGetAll() {
42      AdministrationServiceClient adminClient = Admin.GetClientFactory();
[6160]43
[6317]44      IList<ProblemClass> problemClassList = new List<ProblemClass>();
[6160]45
[6317]46      if (adminClient != null) {
47        ProblemClass[] problemClasses = adminClient.GetProblemClasses();
48        foreach (ProblemClass pc in problemClasses) {
49          problemClassList.Add(pc);
50        }
51      }//if (adminClient != null)
[6160]52
[6317]53      return problemClassList;
54    }//ProblemClassGetAll
[6160]55
[6317]56    private IList<Problem> ProblemsGetAll() {
57      AdministrationServiceClient adminClient = Admin.GetClientFactory();
[6160]58
[6317]59      IList<Problem> problemList = new List<Problem>();
[6160]60
[6317]61      if (adminClient != null) {
62        Problem[] problem = adminClient.GetProblems();
63        foreach (Problem pr in problem) {
64          problemList.Add(pr);
[6160]65
[6317]66        }
67      }//if (adminClient != null)
[6160]68
[6317]69      return problemList;
70    }//ProblemsGetAll
[6160]71
[6317]72    private long AddProblem(Problem problem) {
73      AdministrationServiceClient adminClient = Admin.GetClientFactory();
[6160]74
[6317]75      if (adminClient != null) {
76        return adminClient.AddProblem(problem);
77      }
[6130]78
[6317]79      return 0;
80    }//AddProblem
[6160]81
[6317]82    public void DeleteProblem(long id) {
83      AdministrationServiceClient adminClient = Admin.GetClientFactory();
[6160]84
[6317]85      if (adminClient != null) {
86        adminClient.DeleteProblem(id);
87      }
88    }//DeleteProblem
[6142]89
[6317]90    public long SaveProblem(Problem problem) {
91      AdministrationServiceClient adminClient = Admin.GetClientFactory();
[6130]92
[6317]93      if (adminClient != null) {
94        if (problem.Id == 0) {
95          return AddProblem(problem);
96        } else {
97          Problem pr = adminClient.GetProblem(problem.Id);
[6142]98
[6317]99          if (pr != null) {
100            adminClient.UpdateProblem(problem);
101            return problem.Id;
102          }
103        }
104      }
[6142]105
[6317]106      return 0;
107    }//SaveProblem
[6246]108
[6317]109    public void UpdateProblemData(long id, byte[] data) {
110      AdministrationServiceClient adminClient = Admin.GetClientFactory();
[6246]111
[6317]112      if (adminClient != null) {
113        adminClient.UpdateProblemData(id, data);
114      }
115    }//UpdateProblemData
116  }
[6130]117}
Note: See TracBrowser for help on using the repository browser.