hytos / ID2.Manager / ID2.Manager.Controller / Controllers / ProjectController.cs @ 1018a498
이력 | 보기 | 이력해설 | 다운로드 (3.18 KB)
1 | cab8a4a1 | yoush97 | using System; |
---|---|---|---|
2 | using System.Collections.Generic; |
||
3 | using System.Linq; |
||
4 | using System.Text; |
||
5 | using System.Threading.Tasks; |
||
6 | |||
7 | using ID2.Manager.Data.Models; |
||
8 | using ID2.Manager.Dapper.Repository; |
||
9 | |||
10 | namespace ID2.Manager.Controller.Controllers |
||
11 | { |
||
12 | public class ProjectController : BaseController |
||
13 | { |
||
14 | 87bcedb4 | yoush97 | public IEnumerable<ProjectInfo> GetAllProjectList() |
15 | { |
||
16 | 82705273 | yoush97 | try |
17 | 87bcedb4 | yoush97 | { |
18 | 82705273 | yoush97 | using (ProjectRepository rep = new ProjectRepository(this._MSSQLCONNSTR)) |
19 | { |
||
20 | var id2Project = new ID2Controller().GetID2ProjectList(); |
||
21 | var allProject = rep.GetAllProjectList(); |
||
22 | 87bcedb4 | yoush97 | |
23 | 82705273 | yoush97 | return from mg in allProject |
24 | join id2 in id2Project on mg.Code equals id2.Name into gj |
||
25 | from prjs in gj.DefaultIfEmpty() |
||
26 | select new ProjectInfo() |
||
27 | { |
||
28 | ProjectID = mg.ProjectID, |
||
29 | Code = mg.Code, |
||
30 | Name = mg.Name, |
||
31 | Description = mg.Description, |
||
32 | ID2Path = prjs?.Path ?? null, |
||
33 | GroupID = mg.GroupID, |
||
34 | GroupName = mg.GroupName, |
||
35 | a8981c30 | yoush97 | Team = mg.Team, |
36 | 82705273 | yoush97 | Level = mg.Level, |
37 | ID2Info = prjs ?? new ID2ProjectInfo(), |
||
38 | }; |
||
39 | } |
||
40 | } |
||
41 | catch (Exception ex) |
||
42 | { |
||
43 | throw ex; |
||
44 | cab8a4a1 | yoush97 | } |
45 | } |
||
46 | |||
47 | public ProjectInfo GetProjectInfo(string ProjectID) |
||
48 | { |
||
49 | 82705273 | yoush97 | try |
50 | cab8a4a1 | yoush97 | { |
51 | 82705273 | yoush97 | using (ProjectRepository rep = new ProjectRepository(this._MSSQLCONNSTR)) |
52 | { |
||
53 | var id2Project = new ID2Controller().GetID2ProjectList(); |
||
54 | var project = rep.GetProjectInfo(ProjectID); |
||
55 | 1abdd7c3 | yoush97 | |
56 | 82705273 | yoush97 | var id2 = id2Project.Where(x => x.Name.Equals(project.Code)).FirstOrDefault(); |
57 | project.ID2Path = id2?.Path ?? null; |
||
58 | project.ID2Info = id2 ?? new ID2ProjectInfo(); |
||
59 | 1abdd7c3 | yoush97 | |
60 | 82705273 | yoush97 | return rep.GetProjectInfo(ProjectID); |
61 | } |
||
62 | } |
||
63 | catch (Exception ex) |
||
64 | { |
||
65 | throw ex; |
||
66 | cab8a4a1 | yoush97 | } |
67 | } |
||
68 | a23d0a0c | yoush97 | |
69 | public bool SetProjectData(ProjectInfo projectInfo, List<ID2ProjectInfo> id2ProjectList) |
||
70 | { |
||
71 | 82705273 | yoush97 | try |
72 | a23d0a0c | yoush97 | { |
73 | 82705273 | yoush97 | using (ProjectRepository rep = new ProjectRepository(this._MSSQLCONNSTR)) |
74 | { |
||
75 | return rep.SetProjectData(projectInfo, id2ProjectList); |
||
76 | } |
||
77 | } |
||
78 | catch (Exception ex) |
||
79 | { |
||
80 | throw ex; |
||
81 | a23d0a0c | yoush97 | } |
82 | } |
||
83 | |||
84 | public bool SetProjectGroupData(ProjectInfo projectInfo) |
||
85 | { |
||
86 | 82705273 | yoush97 | try |
87 | { |
||
88 | using (ProjectRepository rep = new ProjectRepository(this._MSSQLCONNSTR)) |
||
89 | { |
||
90 | return rep.SetProjectGroupData(projectInfo); |
||
91 | } |
||
92 | } |
||
93 | catch (Exception ex) |
||
94 | a23d0a0c | yoush97 | { |
95 | 82705273 | yoush97 | throw ex; |
96 | a23d0a0c | yoush97 | } |
97 | } |
||
98 | cab8a4a1 | yoush97 | } |
99 | } |