Free cookie consent management tool by TermsFeed Policy Generator

source: branches/WebApplication/MVC2/HLWebOKBAdminPlugin/Models/PlatformModel.cs @ 6474

Last change on this file since 6474 was 6317, checked in by jwolfing, 13 years ago

#1433 code formatted

File size: 2.1 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Web;
5using HLWebOKBAdminPlugin.OKBAdministrationService;
6using HLWebOKBAdminPlugin.Helpers;
7
8namespace HLWebOKBAdminPlugin.Models {
9  public class PlatformModel {
10    public String SelectedSubMenu { get; set; }
11    public IList<Platform> Platforms {
12      get { return PlatformGetAll(); }
13      set { ;}
14    }
15
16    public Platform Platform { get; set; }
17
18    public PlatformModel() {
19      Platform = new Platform();
20    }//PlatformModel
21
22    //***************************************Platform Class**********************************************
23    private IList<Platform> PlatformGetAll() {
24      AdministrationServiceClient adminClient = Admin.GetClientFactory();
25
26      IList<Platform> platformList = new List<Platform>();
27
28      if (adminClient != null) {
29        Platform[] platforms = adminClient.GetPlatforms();
30        foreach (Platform pl in platforms) {
31          platformList.Add(pl);
32        }
33      }//if (adminClient != null)
34
35      return platformList;
36    }//ProblemClassGetAll               
37
38    private long AddPlatform(Platform plattform) {
39      AdministrationServiceClient adminClient = Admin.GetClientFactory();
40
41      if (adminClient != null) {
42        return adminClient.AddPlatform(plattform);
43      }
44
45      return 0;
46    }//AddPlatform
47
48    public void DeletePlatform(long id) {
49      AdministrationServiceClient adminClient = Admin.GetClientFactory();
50
51      if (adminClient != null) {
52        adminClient.DeletePlatform(id);
53      }
54    }//DeletePlatform
55
56    public long SavePlatform(Platform platform) {
57      AdministrationServiceClient adminClient = Admin.GetClientFactory();
58
59      if (adminClient != null) {
60        if (platform.Id == 0) {
61          return AddPlatform(platform);
62        } else {
63          Platform pl = adminClient.GetPlatform(platform.Id);
64
65          if (pl != null) {
66            adminClient.UpdatePlatform(platform);
67            return platform.Id;
68          }
69        }
70      }
71
72      return 0;
73    }//SavePlatform       
74  }
75}
Note: See TracBrowser for help on using the repository browser.