Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 12209 was 6317, checked in by jwolfing, 13 years ago

#1433 code formatted

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