프로젝트

일반

사용자정보

통계
| 개정판:

hytos / ID2.Manager / ID2.Manager.Controller / Controllers / ProjectController.cs @ c7f3eb42

이력 | 보기 | 이력해설 | 다운로드 (3.14 KB)

1
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
        public IEnumerable<ProjectInfo> GetAllProjectList()
15
        {
16
            try
17
            {
18
                using (ProjectRepository rep = new ProjectRepository(this._MSSQLCONNSTR))
19
                {
20
                    var id2Project = new ID2Controller().GetID2ProjectList();
21
                    var allProject = rep.GetAllProjectList();
22

    
23
                    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
                               Level = mg.Level,
36
                               ID2Info = prjs ?? new ID2ProjectInfo(),
37
                           };
38
                }
39
            }
40
            catch (Exception ex)
41
            {
42
                throw ex;
43
            }
44
        }
45

    
46
        public ProjectInfo GetProjectInfo(string ProjectID)
47
        {
48
            try
49
            {
50
                using (ProjectRepository rep = new ProjectRepository(this._MSSQLCONNSTR))
51
                {
52
                    var id2Project = new ID2Controller().GetID2ProjectList();
53
                    var project = rep.GetProjectInfo(ProjectID);
54

    
55
                    var id2 = id2Project.Where(x => x.Name.Equals(project.Code)).FirstOrDefault();
56
                    project.ID2Path = id2?.Path ?? null;
57
                    project.ID2Info = id2 ?? new ID2ProjectInfo();
58

    
59
                    return rep.GetProjectInfo(ProjectID);
60
                }
61
            }
62
            catch (Exception ex)
63
            {
64
                throw ex;
65
            }
66
        }
67

    
68
        public bool SetProjectData(ProjectInfo projectInfo, List<ID2ProjectInfo> id2ProjectList)
69
        {
70
            try
71
            {
72
                using (ProjectRepository rep = new ProjectRepository(this._MSSQLCONNSTR))
73
                {
74
                    return rep.SetProjectData(projectInfo, id2ProjectList);
75
                }
76
            }
77
            catch (Exception ex)
78
            {
79
                throw ex;
80
            }
81
        }
82

    
83
        public bool SetProjectGroupData(ProjectInfo projectInfo)
84
        {
85
            try
86
            {
87
                using (ProjectRepository rep = new ProjectRepository(this._MSSQLCONNSTR))
88
                {
89
                    return rep.SetProjectGroupData(projectInfo);
90
                }
91
            }
92
            catch (Exception ex)
93
            {
94
                throw ex;
95
            }
96
        }
97
    }
98
}
클립보드 이미지 추가 (최대 크기: 500 MB)