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

Last change on this file since 5005 was 5005, checked in by wtollsch, 12 years ago

#1198 AddAlgorithmClass: prototype test successful... new AlgorithmClass added from HLWebOKBAdminPlugin

File size: 2.1 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Web;
5using System.ServiceModel.Security;
6using System.Web.Security;
7
8namespace HLWebPluginHost.Models {
9    public class AlgorithmClassModel {
10
11        public int NumOfClasses { get; set; }
12        public List<OKBService.AlgorithmClass> AlgorithmClassList { get; set; }
13
14        public List<OKBService.AlgorithmClass> AlgorithmClassGetAll() {
15            //returns list of algorithm classes
16            OKBService.OKBServiceClient sc = new OKBService.OKBServiceClient();
17            sc.ClientCredentials.UserName.UserName = Membership.GetUser().UserName;
18            sc.ClientCredentials.UserName.Password = HttpContext.Current.Session["pwd"].ToString();
19            sc.ClientCredentials.ServiceCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.None;
20
21            var agcList = new List<OKBService.AlgorithmClass>();
22
23            OKBService.AlgorithmClass[] ac = sc.GetAlgorithmClasses();
24            foreach (OKBService.AlgorithmClass a in ac) {
25                agcList.Add(a);
26
27            }//foreach
28
29            return agcList;
30        }//AlgorithmClassGetAll
31
32        //Add AlgorithmClass table entry
33        public bool AddAlgorithmClass(string name, string description) {
34            long retValue;
35            //get service client
36            OKBService.OKBServiceClient sc = new OKBService.OKBServiceClient();
37            sc.ClientCredentials.UserName.UserName = Membership.GetUser().UserName;
38            sc.ClientCredentials.UserName.Password = HttpContext.Current.Session["pwd"].ToString();
39            sc.ClientCredentials.ServiceCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.None;
40
41            OKBService.AlgorithmClass ac = new OKBService.AlgorithmClass();
42            //test
43            //ac.Id = 8;
44            ac.Name = name;
45            ac.Description = description;
46            retValue = sc.AddAlgorithmClass(ac);
47           
48            return true;
49        }//AddAlgorithmClass
50    }
51}
Note: See TracBrowser for help on using the repository browser.