Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/07/11 13:51:37 (13 years ago)
Author:
wtollsch
Message:

#1433 modified model

File:
1 edited

Legend:

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

    r5700 r6143  
    66using System.Web.Security;
    77using HLWebOKBAdminPlugin.OKBAdministrationService;
     8using HLWebOKBAdminPlugin.Helpers;
    89
    910namespace HLWebPluginHost.Models {
    10     public class AlgorithmClassModel {
     11    public class AlgorithmClassModel {       
    1112
    12         private AdministrationServiceClient CertificateValidator() {
    13             AdministrationServiceClient asc = new AdministrationServiceClient();
     13        public String SelectedSubMenu { get; set; }
     14        public IList<AlgorithmClass> AlgorithmClasses { get { return AlgorithmClassGetAll(); } }
    1415
    15             asc.ClientCredentials.UserName.UserName = Membership.GetUser().UserName;
    16             asc.ClientCredentials.UserName.Password = HttpContext.Current.Session["pwd"].ToString();
    17             asc.ClientCredentials.ServiceCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.None;
    1816
    19             return asc;
    20         }//CertificateValidator
     17        //***************************************Algorithm Class********************************************
     18        //get all algorithm classes
     19        private IList<AlgorithmClass> AlgorithmClassGetAll() {
     20            AdministrationServiceClient adminClient = Admin.GetClientFactory();
    2121
    22         public int NumOfClasses { get; set; }
    23         public List<AlgorithmClass> AlgorithmClassList { get; set; }
     22            IList<AlgorithmClass>  algorithmClassList = new List<AlgorithmClass>();
    2423
    25         public List<AlgorithmClass> AlgorithmClassGetAll() {
    26             //returns list of algorithm classes           
    27             AdministrationServiceClient asc = CertificateValidator();
     24            if (adminClient != null) {
     25                AlgorithmClass[] algorithmClasses = adminClient.GetAlgorithmClasses();
     26                foreach (AlgorithmClass ac in algorithmClasses) {
     27                    algorithmClassList.Add(ac);
    2828
    29             var agcList = new List<AlgorithmClass>();
     29                }
     30            }//if (adminClient != null)
    3031
    31             AlgorithmClass[] ac = asc.GetAlgorithmClasses();
    32             foreach (AlgorithmClass a in ac) {
    33                 agcList.Add(a);
    34 
    35             }//foreach
    36 
    37             return agcList;
     32            return algorithmClassList;
    3833        }//AlgorithmClassGetAll
    3934
    40         //Add AlgorithmClass table entry
    41         public bool AddAlgorithmClass(string name, string description) {
    42             long retValue;
    43             //get service client
    44             AdministrationServiceClient asc = CertificateValidator();
     35        private long AddAlgorithmClass(AlgorithmClass algorithmClass) {
     36            AdministrationServiceClient adminClient = Admin.GetClientFactory();
    4537
    46             AlgorithmClass ac = new AlgorithmClass();
    47             //test
    48             //ac.Id = 8;
    49             ac.Name = name;
    50             ac.Description = description;
    51             retValue = asc.AddAlgorithmClass(ac);
    52            
    53             return true;
     38            if (adminClient != null) {
     39                return adminClient.AddAlgorithmClass(algorithmClass);
     40            }
     41
     42            return 0;
    5443        }//AddAlgorithmClass
     44
     45        public void DeleteAlgorithmClass(long id) {
     46            AdministrationServiceClient adminClient = Admin.GetClientFactory();
     47
     48            if (adminClient != null) {
     49                adminClient.DeleteAlgorithmClass(id);
     50            }
     51        }//DeleteAlgorithmClass
     52
     53        public long SaveAlgorithmClass(AlgorithmClass algorithmClass) {
     54            AdministrationServiceClient adminClient = Admin.GetClientFactory();
     55
     56            if (adminClient != null) {
     57                if (algorithmClass.Id == 0) {
     58                    return AddAlgorithmClass(algorithmClass);
     59                }
     60                else {
     61                    AlgorithmClass ac = adminClient.GetAlgorithmClass(algorithmClass.Id);
     62
     63                    if (ac != null) {
     64                        adminClient.UpdateAlgorithmClass(algorithmClass);
     65                        return algorithmClass.Id;
     66                    }
     67                }
     68            }
     69
     70            return 0;
     71        }//SaveAlgorithmClass               
    5572    }
    5673}
Note: See TracChangeset for help on using the changeset viewer.