프로젝트

일반

사용자정보

통계
| 개정판:

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

이력 | 보기 | 이력해설 | 다운로드 (2.48 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
            using (ProjectRepository rep = new ProjectRepository(this._MSSQLCONNSTR))
17
            {
18
                var id2Project = new ID2Controller().GetID2ProjectList();
19
                var allProject = rep.GetAllProjectList();
20

    
21
                return from mg in allProject
22
                       join id2 in id2Project on mg.Code equals id2.Name into gj
23
                       from prjs in gj.DefaultIfEmpty()
24
                       select new ProjectInfo()
25
                       {
26
                           ProjectID = mg.ProjectID,
27
                           Code = mg.Code,
28
                           Name = mg.Name,
29
                           Description = mg.Description,
30
                           ID2Path = prjs?.Path ?? null,
31
                           GroupID = mg.GroupID,
32
                           GroupName = mg.GroupName,
33
                           Level = mg.Level,
34
                           ID2Info = prjs ?? new ID2ProjectInfo(),
35
                       };
36
            }
37
        }
38

    
39
        public ProjectInfo GetProjectInfo(string ProjectID)
40
        {
41
            using (ProjectRepository rep = new ProjectRepository(this._MSSQLCONNSTR))
42
            {
43
                var id2Project = new ID2Controller().GetID2ProjectList();
44
                var project = rep.GetProjectInfo(ProjectID);
45

    
46
                var id2 = id2Project.Where(x => x.Name.Equals(project.Code)).FirstOrDefault();
47
                project.ID2Path = id2?.Path ?? null;
48
                project.ID2Info = id2 ?? new ID2ProjectInfo();
49

    
50
                return rep.GetProjectInfo(ProjectID);
51
            }
52
        }
53

    
54
        public bool SetProjectData(ProjectInfo projectInfo, List<ID2ProjectInfo> id2ProjectList)
55
        {
56
            using (ProjectRepository rep = new ProjectRepository(this._MSSQLCONNSTR))
57
            {
58
                return rep.SetProjectData(projectInfo, id2ProjectList);
59
            }
60
        }
61

    
62
        public bool SetProjectGroupData(ProjectInfo projectInfo)
63
        {
64
            using (ProjectRepository rep = new ProjectRepository(this._MSSQLCONNSTR))
65
            {
66
                return rep.SetProjectGroupData(projectInfo);
67
            }
68
        }
69
    }
70
}
클립보드 이미지 추가 (최대 크기: 500 MB)