예제 #1
0
        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();
            }
        }
예제 #2
0
        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();
            }
        }