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(); } }); }