Free cookie consent management tool by TermsFeed Policy Generator

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

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

#1433 code formatted

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