예제 #1
0
파일: DbAccess.cs 프로젝트: FTim/ch
        public static async Task AddProjectAsync(ProjectDTO projectDTO)
        {
            await Task.Run(() =>
            {
                using (var db = new ChContext())
                {
                    var project    = projectDTO.TransformToProject();
                    project.Leader = db.People.Where(p => p.Name == projectDTO.Leader).First();

                    var projectplan = new ProjectPlan {
                        img = projectDTO.PlanImg, Project = project
                    };

                    db.Projects.Add(project);
                    db.ProjectPlans.Add(projectplan);

                    db.SaveChanges();
                }
            });
        }