Free cookie consent management tool by TermsFeed Policy Generator

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

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

#1433 update

File size: 3.6 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{
10    public class ProblemModel {
11
12        public String SelectedSubMenu { get; set; }
13        public IList<Problem> Problems { get { return ProblemsGetAll(); } set { ;} }
14        public IList<ProblemClass> ProblemClasses { get { return ProblemClassGetAll(); } }
15        public IList<Platform> Platforms { get { return PlatformsGetAll(); } }
16
17        public Problem Problem { get; set; }
18
19        public ProblemModel() {
20            Problem = new Problem();
21        }//ProblemModel
22
23        //***************************************Problems***************************************************
24        private IList<Platform> PlatformsGetAll() {
25            AdministrationServiceClient adminClient = Admin.GetClientFactory();
26
27            IList<Platform> platformList = new List<Platform>();
28
29            if (adminClient != null) {
30                Platform[] platforms = adminClient.GetPlatforms();
31                foreach (Platform pl in platforms) {
32                    platformList.Add(pl);
33                }
34            }//if (adminClient != null)
35
36            return platformList;
37        }//ProblemClassGetAll
38
39        private IList<ProblemClass> ProblemClassGetAll() {
40            AdministrationServiceClient adminClient = Admin.GetClientFactory();
41
42            IList<ProblemClass> problemClassList = new List<ProblemClass>();
43
44            if (adminClient != null) {
45                ProblemClass[] problemClasses = adminClient.GetProblemClasses();
46                foreach (ProblemClass pc in problemClasses) {
47                    problemClassList.Add(pc);
48                }
49            }//if (adminClient != null)
50
51            return problemClassList;
52        }//ProblemClassGetAll
53
54        private IList<Problem> ProblemsGetAll() {
55            AdministrationServiceClient adminClient = Admin.GetClientFactory();
56
57            IList<Problem> problemList = new List<Problem>();
58
59            if (adminClient != null) {
60                Problem[] problem = adminClient.GetProblems();
61                foreach (Problem pr in problem) {
62                    problemList.Add(pr);
63
64                }
65            }//if (adminClient != null)
66
67            return problemList;
68        }//ProblemsGetAll
69
70        private long AddProblem(Problem problem) {
71            AdministrationServiceClient adminClient = Admin.GetClientFactory();
72
73            if (adminClient != null) {
74                return adminClient.AddProblem(problem);
75            }
76
77            return 0;
78        }//AddProblem
79
80        public void DeleteProblem(long id) {
81            AdministrationServiceClient adminClient = Admin.GetClientFactory();
82
83            if (adminClient != null) {
84                adminClient.DeleteProblem(id);
85            }
86        }//DeleteProblem
87
88        public long SaveProblem(Problem problem) {
89            AdministrationServiceClient adminClient = Admin.GetClientFactory();
90
91            if (adminClient != null) {
92                if (problem.Id == 0) {
93                    return AddProblem(problem);
94                }
95                else {
96                    Problem pr = adminClient.GetProblem(problem.Id);
97
98                    if (pr != null) {
99                        adminClient.UpdateProblem(problem);
100                        return problem.Id;
101                    }
102                }
103            }
104
105            return 0;
106        }//SaveProblem
107    }
108}
Note: See TracBrowser for help on using the repository browser.