Free cookie consent management tool by TermsFeed Policy Generator

source: branches/WebApplication/MVC2/HLWebOKBAdminPlugin/Models/ProblemClassModel.cs @ 6474

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

#1433 code formatted

File size: 2.7 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 ProblemClassModel {
10
11    public String SelectedSubMenu { get; set; }
12    public IList<ProblemClass> ProblemClasses {
13      get { return ProblemClassGetAll(); }
14      set { ;}
15    }
16
17    public ProblemClass ProblemClass { get; set; }
18
19    public ProblemClassModel() {
20      ProblemClass = new ProblemClass();
21    }//ProblemClassModel
22
23    //***************************************Problem Class**********************************************
24    private IList<Platform> PlatformsGetAll() {
25      AdministrationServiceClient adminClient = Admin.GetClientFactory();
26
27      IList<Platform> platformList = new List<Platform>();
28
29      if (adminClient != null) {
30        Platform[] platforms = adminClient.GetPlatforms();
31        foreach (Platform pl in platforms) {
32          platformList.Add(pl);
33        }
34      }//if (adminClient != null)
35
36      return platformList;
37    }//ProblemClassGetAll
38
39    private IList<ProblemClass> ProblemClassGetAll() {
40      AdministrationServiceClient adminClient = Admin.GetClientFactory();
41
42      IList<ProblemClass> problemClassList = new List<ProblemClass>();
43
44      if (adminClient != null) {
45        ProblemClass[] problemClasses = adminClient.GetProblemClasses();
46        foreach (ProblemClass pc in problemClasses) {
47          problemClassList.Add(pc);
48        }
49      }//if (adminClient != null)
50
51      return problemClassList;
52    }//ProblemClassGetAll
53
54    private long AddProblemClass(ProblemClass problemClass) {
55      AdministrationServiceClient adminClient = Admin.GetClientFactory();
56
57      if (adminClient != null) {
58        return adminClient.AddProblemClass(problemClass);
59      }
60
61      return 0;
62    }//AddProblemClass
63
64    public void DeleteProblemClass(long id) {
65      AdministrationServiceClient adminClient = Admin.GetClientFactory();
66
67      if (adminClient != null) {
68        adminClient.DeleteProblemClass(id);
69      }
70    }//DeleteProblemClass
71
72    public long SaveProblemClass(ProblemClass problemClass) {
73      AdministrationServiceClient adminClient = Admin.GetClientFactory();
74
75      if (adminClient != null) {
76        if (problemClass.Id == 0) {
77          return AddProblemClass(problemClass);
78        } else {
79          ProblemClass pc = adminClient.GetProblemClass(problemClass.Id);
80
81          if (pc != null) {
82            adminClient.UpdateProblemClass(problemClass);
83            return problemClass.Id;
84          }
85        }
86      }
87
88      return 0;
89    }//SaveProblemClass       
90  }
91}
Note: See TracBrowser for help on using the repository browser.