1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.Linq;
|
---|
4 | using System.Web;
|
---|
5 | using HLWebOKBAdminPlugin.OKBAdministrationService;
|
---|
6 | using HLWebOKBAdminPlugin.Helpers;
|
---|
7 |
|
---|
8 | namespace 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 | } |
---|