public static void Create(int projectId, string[] selection) { using (var db = new ViolaContext()) { // mevcut iliþkiler silinir. foreach (var row in db.ProjectTeams.Where(x => x.ProjectId == projectId)) { db.ProjectTeams.Remove(row); } // yeni iliþkiler kaydedilir if (selection != null) { foreach (var id in selection) { var row = new ProjectTeam { ProjectId = projectId, UserId = id }; row.InitCreateValue(); db.ProjectTeams.Add(row); } } db.SaveChanges(); } }
public static void AddProjectManagerToTeam(Project project) { var db = new ViolaContext(); if (!ProjectTeam.Exist(project.Id, project.ManagerUserId)) { var pt = new ProjectTeam() { ProjectId = project.Id, UserId = project.ManagerUserId }; pt.InitCreateValue(); db.ProjectTeams.Add(pt); db.SaveChanges(); } }