public void CreateNewProject(int userId, ProjectData data) { using (var context = new ProjectManagerDBEntities()) { var project = new Project() { Name = data.Name, Description = data.Description, Deadline = data.Deadline, Done = data.Done, CreatedDate = DateTime.Now }; context.Project.Add(project); context.Role.Add(new Role() { ProjectUserId = userId, Type = new ProjectUserManager().GetLeaderId(), Project = project }); context.SaveChanges(); } }