Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 6160 was 6144, checked in by wtollsch, 14 years ago

#1433 add property AlgorithmClass

File size: 2.6 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Web;
5using System.ServiceModel.Security;
6using System.Web.Security;
7using HLWebOKBAdminPlugin.OKBAdministrationService;
8using HLWebOKBAdminPlugin.Helpers;
9
10namespace HLWebOKBAdminPlugin.Models {
11    public class AlgorithmClassModel {       
12
13        public String SelectedSubMenu { get; set; }
14        public IList<AlgorithmClass> AlgorithmClasses { get { return AlgorithmClassGetAll(); } }
15
16        public AlgorithmClass AlgorithmClass { get; set; }
17
18        //***************************************Algorithm Class********************************************
19        //get all algorithm classes
20        private IList<AlgorithmClass> AlgorithmClassGetAll() {
21            AdministrationServiceClient adminClient = Admin.GetClientFactory();
22
23            IList<AlgorithmClass>  algorithmClassList = new List<AlgorithmClass>();
24
25            if (adminClient != null) {
26                AlgorithmClass[] algorithmClasses = adminClient.GetAlgorithmClasses();
27                foreach (AlgorithmClass ac in algorithmClasses) {
28                    algorithmClassList.Add(ac);
29
30                }
31            }//if (adminClient != null)
32
33            return algorithmClassList;
34        }//AlgorithmClassGetAll
35
36        private long AddAlgorithmClass(AlgorithmClass algorithmClass) {
37            AdministrationServiceClient adminClient = Admin.GetClientFactory();
38
39            if (adminClient != null) {
40                return adminClient.AddAlgorithmClass(algorithmClass);
41            }
42
43            return 0;
44        }//AddAlgorithmClass
45
46        public void DeleteAlgorithmClass(long id) {
47            AdministrationServiceClient adminClient = Admin.GetClientFactory();
48
49            if (adminClient != null) {
50                adminClient.DeleteAlgorithmClass(id);
51            }
52        }//DeleteAlgorithmClass
53
54        public long SaveAlgorithmClass(AlgorithmClass algorithmClass) {
55            AdministrationServiceClient adminClient = Admin.GetClientFactory();
56
57            if (adminClient != null) {
58                if (algorithmClass.Id == 0) {
59                    return AddAlgorithmClass(algorithmClass);
60                }
61                else {
62                    AlgorithmClass ac = adminClient.GetAlgorithmClass(algorithmClass.Id);
63
64                    if (ac != null) {
65                        adminClient.UpdateAlgorithmClass(algorithmClass);
66                        return algorithmClass.Id;
67                    }
68                }
69            }
70
71            return 0;
72        }//SaveAlgorithmClass               
73    }
74}
Note: See TracBrowser for help on using the repository browser.