Free cookie consent management tool by TermsFeed Policy Generator

source: branches/WebApplication/MVC2/HLWebOKBAdminPlugin/Models/AlgorithmClassModel.cs @ 11255

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

#1433 code formatted

File size: 3.4 KB
RevLine 
[4985]1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Web;
5using System.ServiceModel.Security;
6using System.Web.Security;
[5700]7using HLWebOKBAdminPlugin.OKBAdministrationService;
[6143]8using HLWebOKBAdminPlugin.Helpers;
[4985]9
[6144]10namespace HLWebOKBAdminPlugin.Models {
[6317]11  public class AlgorithmClassModel {
[4985]12
[6317]13    public String SelectedSubMenu { get; set; }
14    public IList<AlgorithmClass> AlgorithmClasses {
15      get { return AlgorithmClassGetAll(); }
16      set { ;}
17    }
[5700]18
[6317]19    public AlgorithmClass AlgorithmClass { get; set; }
[5700]20
[6317]21    public AlgorithmClassModel() {
22      AlgorithmClass = new AlgorithmClass();
23    }//AlgorithmClassModel
[6161]24
[6317]25    //***************************************Algorithm Class********************************************
26    private IList<Platform> PlatformsGetAll() {
27      AdministrationServiceClient adminClient = Admin.GetClientFactory();
[6161]28
[6317]29      IList<Platform> platformList = new List<Platform>();
[6161]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)
[6161]37
[6317]38      return platformList;
39    }//ProblemClassGetAll
[6161]40
[6317]41    private IList<ProblemClass> ProblemClassGetAll() {
42      AdministrationServiceClient adminClient = Admin.GetClientFactory();
[6161]43
[6317]44      IList<ProblemClass> problemClassList = new List<ProblemClass>();
[6161]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)
[6161]52
[6317]53      return problemClassList;
54    }//ProblemClassGetAll
[6161]55
[6317]56    //get all algorithm classes
57    private IList<AlgorithmClass> AlgorithmClassGetAll() {
58      AdministrationServiceClient adminClient = Admin.GetClientFactory();
[5700]59
[6317]60      IList<AlgorithmClass> algorithmClassList = new List<AlgorithmClass>();
[4985]61
[6317]62      if (adminClient != null) {
63        AlgorithmClass[] algorithmClasses = adminClient.GetAlgorithmClasses();
64        foreach (AlgorithmClass ac in algorithmClasses) {
65          algorithmClassList.Add(ac);
[4985]66
[6317]67        }
68      }//if (adminClient != null)
[4985]69
[6317]70      return algorithmClassList;
71    }//AlgorithmClassGetAll
[4985]72
[6317]73    private long AddAlgorithmClass(AlgorithmClass algorithmClass) {
74      AdministrationServiceClient adminClient = Admin.GetClientFactory();
[4985]75
[6317]76      if (adminClient != null) {
77        return adminClient.AddAlgorithmClass(algorithmClass);
78      }
[4985]79
[6317]80      return 0;
81    }//AddAlgorithmClass
[4985]82
[6317]83    public void DeleteAlgorithmClass(long id) {
84      AdministrationServiceClient adminClient = Admin.GetClientFactory();
[6143]85
[6317]86      if (adminClient != null) {
87        adminClient.DeleteAlgorithmClass(id);
88      }
89    }//DeleteAlgorithmClass
[6143]90
[6317]91    public long SaveAlgorithmClass(AlgorithmClass algorithmClass) {
92      AdministrationServiceClient adminClient = Admin.GetClientFactory();
[6143]93
[6317]94      if (adminClient != null) {
95        if (algorithmClass.Id == 0) {
96          return AddAlgorithmClass(algorithmClass);
97        } else {
98          AlgorithmClass ac = adminClient.GetAlgorithmClass(algorithmClass.Id);
[6143]99
[6317]100          if (ac != null) {
101            adminClient.UpdateAlgorithmClass(algorithmClass);
102            return algorithmClass.Id;
103          }
104        }
105      }
[6143]106
[6317]107      return 0;
108    }//SaveAlgorithmClass               
109  }
[4985]110}
Note: See TracBrowser for help on using the repository browser.