Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/27/11 19:09:49 (13 years ago)
Author:
jwolfing
Message:

#1433 code formatted

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/WebApplication/MVC2/HLWebOKBAdminPlugin/Models/AlgorithmClassModel.cs

    r6246 r6317  
    99
    1010namespace HLWebOKBAdminPlugin.Models {
    11     public class AlgorithmClassModel {       
     11  public class AlgorithmClassModel {
    1212
    13         public String SelectedSubMenu { get; set; }
    14         public IList<AlgorithmClass> AlgorithmClasses {
    15             get { return AlgorithmClassGetAll(); }
    16             set { ;}
     13    public String SelectedSubMenu { get; set; }
     14    public IList<AlgorithmClass> AlgorithmClasses {
     15      get { return AlgorithmClassGetAll(); }
     16      set { ;}
     17    }
     18
     19    public AlgorithmClass AlgorithmClass { get; set; }
     20
     21    public AlgorithmClassModel() {
     22      AlgorithmClass = new AlgorithmClass();
     23    }//AlgorithmClassModel
     24
     25    //***************************************Algorithm Class********************************************
     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);
    1735        }
     36      }//if (adminClient != null)
    1837
    19         public AlgorithmClass AlgorithmClass { get; set; }
     38      return platformList;
     39    }//ProblemClassGetAll
    2040
    21         public AlgorithmClassModel() {
    22             AlgorithmClass = new AlgorithmClass();
    23         }//AlgorithmClassModel
     41    private IList<ProblemClass> ProblemClassGetAll() {
     42      AdministrationServiceClient adminClient = Admin.GetClientFactory();
    2443
    25         //***************************************Algorithm Class********************************************
    26         private IList<Platform> PlatformsGetAll() {
    27             AdministrationServiceClient adminClient = Admin.GetClientFactory();
     44      IList<ProblemClass> problemClassList = new List<ProblemClass>();
    2845
    29             IList<Platform> platformList = new List<Platform>();
     46      if (adminClient != null) {
     47        ProblemClass[] problemClasses = adminClient.GetProblemClasses();
     48        foreach (ProblemClass pc in problemClasses) {
     49          problemClassList.Add(pc);
     50        }
     51      }//if (adminClient != null)
    3052
    31             if (adminClient != null) {
    32                 Platform[] platforms = adminClient.GetPlatforms();
    33                 foreach (Platform pl in platforms) {
    34                     platformList.Add(pl);
    35                 }
    36             }//if (adminClient != null)
     53      return problemClassList;
     54    }//ProblemClassGetAll
    3755
    38             return platformList;
    39         }//ProblemClassGetAll
     56    //get all algorithm classes
     57    private IList<AlgorithmClass> AlgorithmClassGetAll() {
     58      AdministrationServiceClient adminClient = Admin.GetClientFactory();
    4059
    41         private IList<ProblemClass> ProblemClassGetAll() {
    42             AdministrationServiceClient adminClient = Admin.GetClientFactory();
     60      IList<AlgorithmClass> algorithmClassList = new List<AlgorithmClass>();
    4361
    44             IList<ProblemClass> problemClassList = new List<ProblemClass>();
     62      if (adminClient != null) {
     63        AlgorithmClass[] algorithmClasses = adminClient.GetAlgorithmClasses();
     64        foreach (AlgorithmClass ac in algorithmClasses) {
     65          algorithmClassList.Add(ac);
    4566
    46             if (adminClient != null) {
    47                 ProblemClass[] problemClasses = adminClient.GetProblemClasses();
    48                 foreach (ProblemClass pc in problemClasses) {
    49                     problemClassList.Add(pc);
    50                 }
    51             }//if (adminClient != null)
     67        }
     68      }//if (adminClient != null)
    5269
    53             return problemClassList;
    54         }//ProblemClassGetAll
     70      return algorithmClassList;
     71    }//AlgorithmClassGetAll
    5572
    56         //get all algorithm classes
    57         private IList<AlgorithmClass> AlgorithmClassGetAll() {
    58             AdministrationServiceClient adminClient = Admin.GetClientFactory();
     73    private long AddAlgorithmClass(AlgorithmClass algorithmClass) {
     74      AdministrationServiceClient adminClient = Admin.GetClientFactory();
    5975
    60             IList<AlgorithmClass>  algorithmClassList = new List<AlgorithmClass>();
     76      if (adminClient != null) {
     77        return adminClient.AddAlgorithmClass(algorithmClass);
     78      }
    6179
    62             if (adminClient != null) {
    63                 AlgorithmClass[] algorithmClasses = adminClient.GetAlgorithmClasses();
    64                 foreach (AlgorithmClass ac in algorithmClasses) {
    65                     algorithmClassList.Add(ac);
     80      return 0;
     81    }//AddAlgorithmClass
    6682
    67                 }
    68             }//if (adminClient != null)
     83    public void DeleteAlgorithmClass(long id) {
     84      AdministrationServiceClient adminClient = Admin.GetClientFactory();
    6985
    70             return algorithmClassList;
    71         }//AlgorithmClassGetAll
     86      if (adminClient != null) {
     87        adminClient.DeleteAlgorithmClass(id);
     88      }
     89    }//DeleteAlgorithmClass
    7290
    73         private long AddAlgorithmClass(AlgorithmClass algorithmClass) {
    74             AdministrationServiceClient adminClient = Admin.GetClientFactory();
     91    public long SaveAlgorithmClass(AlgorithmClass algorithmClass) {
     92      AdministrationServiceClient adminClient = Admin.GetClientFactory();
    7593
    76             if (adminClient != null) {
    77                 return adminClient.AddAlgorithmClass(algorithmClass);
    78             }
     94      if (adminClient != null) {
     95        if (algorithmClass.Id == 0) {
     96          return AddAlgorithmClass(algorithmClass);
     97        } else {
     98          AlgorithmClass ac = adminClient.GetAlgorithmClass(algorithmClass.Id);
    7999
    80             return 0;
    81         }//AddAlgorithmClass
     100          if (ac != null) {
     101            adminClient.UpdateAlgorithmClass(algorithmClass);
     102            return algorithmClass.Id;
     103          }
     104        }
     105      }
    82106
    83         public void DeleteAlgorithmClass(long id) {
    84             AdministrationServiceClient adminClient = Admin.GetClientFactory();
    85 
    86             if (adminClient != null) {
    87                 adminClient.DeleteAlgorithmClass(id);
    88             }
    89         }//DeleteAlgorithmClass
    90 
    91         public long SaveAlgorithmClass(AlgorithmClass algorithmClass) {
    92             AdministrationServiceClient adminClient = Admin.GetClientFactory();
    93 
    94             if (adminClient != null) {
    95                 if (algorithmClass.Id == 0) {
    96                     return AddAlgorithmClass(algorithmClass);
    97                 }
    98                 else {
    99                     AlgorithmClass ac = adminClient.GetAlgorithmClass(algorithmClass.Id);
    100 
    101                     if (ac != null) {
    102                         adminClient.UpdateAlgorithmClass(algorithmClass);
    103                         return algorithmClass.Id;
    104                     }
    105                 }
    106             }
    107 
    108             return 0;
    109         }//SaveAlgorithmClass               
    110     }
     107      return 0;
     108    }//SaveAlgorithmClass               
     109  }
    111110}
Note: See TracChangeset for help on using the changeset viewer.