コード例 #1
0
 protected override TeamModel AddTeam()
 {
     EFTeamRepository teams = new EFTeamRepository { CreateContext = GetContext };
     var newTeam = new TeamModel { Name="Team1" };
     teams.Create(newTeam);
     return newTeam;
 }
コード例 #2
0
 protected override TeamModel CreateTeam()
 {
     var newTeam = new TeamModel { Name = "Team1", Id = Guid.NewGuid() };
     newTeam.Members = new UserModel[0];
     ADBackend.Instance.Teams.Add(newTeam);
     return newTeam;
 }
コード例 #3
0
        public bool Create(TeamModel model)
        {
            if (model == null) throw new ArgumentException("team");
            if (model.Name == null) throw new ArgumentException("name");

            using (var database = new DataEntities())
            {
                var team = new Team
                {
                    Name = model.Name,
                    Description = model.Description
                };
                database.AddToTeam(team);
                if (model.Members != null)
                {
                    AddMembers(model.Members, team, database);
                }
                try
                {
                    database.SaveChanges();
                }
                catch (UpdateException)
                {
                    return false;
                }
            }

            return true;
        }
コード例 #4
0
        public void DeletingMissingTeamIsSilentlyIgnored()
        {
            var team1 = new TeamModel { Name = "Team1", Description = "Test Team" };
            CreateTeam(team1);

            _repo.Delete(Guid.NewGuid());

            Assert.AreEqual("Team1", _repo.GetAllTeams().Single().Name);
        }
コード例 #5
0
        public void TeamCanBeDeleted()
        {
            var team1 = new TeamModel { Name = "Team1", Description = "Test Team" };
            CreateTeam(team1);
            var team2 = new TeamModel { Name = "Team2", Description = "Test Team" };
            CreateTeam(team2);

            _repo.Delete(team1.Id);

            Assert.AreEqual("Team2", _repo.GetAllTeams().Single().Name);
        }
コード例 #6
0
        public void EnsureCollectionsAreValid()
        {
            if (Administrators == null)
            {
                Administrators = new UserModel[0];
            }

            if (Users == null)
            {
                Users = new UserModel[0];
            }

            if (Teams == null)
            {
                Teams = new TeamModel[0];
            }
        }
コード例 #7
0
        public bool Create(TeamModel model)
        {
            if (model == null) throw new ArgumentException("team");
            if (model.Name == null) throw new ArgumentException("name");

            using (var database = CreateContext())
            {
                // Write this into the model so that the caller knows the ID of the new itel
                model.Id = Guid.NewGuid();
                var team = new Team
                {
                    Id = model.Id,
                    Name = model.Name,
                    Description = model.Description
                };
                database.Teams.Add(team);
                if (model.Members != null)
                {
                    AddMembers(model.Members.Select(x => x.Id), team, database);
                }
                try
                {
                    database.SaveChanges();
                }
                catch (DbUpdateException)
                {
                    return false;
                }
                catch (UpdateException)
                {
                    // Not sure when this exception happens - DbUpdateException is what you get for adding a duplicate teamname
                    return false;
                }
            }

            return true;
        }
コード例 #8
0
 protected override void UpdateTeam(TeamModel team)
 {
     ADBackend.Instance.Teams.AddOrUpdate(team);
 }
コード例 #9
0
 private TeamDetailModel ConvertTeamModel(TeamModel model)
 {
     return model == null ? null : new TeamDetailModel
     {
         Name = model.Name,
         Description = model.Description,
         Members = model.Members,
         Repositories = RepositoryRepository.GetPermittedRepositories(null, new[] { model.Name }).Select(x => x.Name).ToArray(),
         IsReadOnly = MembershipService.IsReadOnly()
     };
 }
コード例 #10
0
 protected override void UpdateTeam(TeamModel team)
 {
     _teams.Update(team);
 }
コード例 #11
0
 public bool Create(TeamModel team)
 {
     throw new NotImplementedException();
 }
コード例 #12
0
 private TeamEditModel ConvertEditTeamModel(TeamModel model)
 {
     return model == null ? null : new TeamEditModel
     {
         Id = model.Id,
         Name = model.Name,
         Description = model.Description,
         AllUsers = MembershipService.GetAllUsers().ToArray(),
         SelectedUsers = model.Members.ToArray(),
     };
 }
コード例 #13
0
 private TeamModel CreateTeam()
 {
     EFTeamRepository teams = new EFTeamRepository { CreateContext = GetContext };
     var newTeam = new TeamModel { Name = "Team1" };
     teams.Create(newTeam);
     return newTeam;
 }
コード例 #14
0
 protected override TeamModel CreateTeam()
 {
     var newTeam = new TeamModel { Name = "Team1" };
     _teams.Create(newTeam);
     return newTeam;
 }
コード例 #15
0
        private void UpdateTeams()
        {
            foreach (string team in Teams.Select(x => x.Name).Where(x => !ActiveDirectorySettings.TeamNameToGroupNameMapping.Keys.Contains(x, StringComparer.OrdinalIgnoreCase)))
            {
                Teams.Remove(team);
            }

            using (PrincipalContext principalContext = new PrincipalContext(ContextType.Domain, ActiveDirectorySettings.DefaultDomain))
            {
                foreach (string teamName in ActiveDirectorySettings.TeamNameToGroupNameMapping.Keys)
                {
                    try
                    {
                        using (GroupPrincipal group = GroupPrincipal.FindByIdentity(principalContext, IdentityType.Name, ActiveDirectorySettings.TeamNameToGroupNameMapping[teamName]))
                        {
                            TeamModel teamModel = new TeamModel() { Description = group.Description, Name = teamName, Members = group.GetMembers(true).Select(x => x.UserPrincipalName).ToArray() };
                            if (teamModel != null)
                            {
                                Teams.AddOrUpdate(teamModel);
                            }
                        }
                    }
                    catch
                    {
                    }
                }
            }
        }
コード例 #16
0
        public void TeamCanBeUpdatedToIncludeAUser()
        {
            var team1 = new TeamModel { Name = "Team1", Description = "Test Team" };
            CreateTeam(team1);

            var newUser = AddUserFred();

            _repo.UpdateUserTeams(newUser.Id, new List<string> { "Team1"});

            Assert.AreEqual(1, _repo.GetTeams(newUser.Id).Count);
            CollectionAssert.AreEqual(new[] { newUser.Id }, _repo.GetTeam(team1.Id).Members.Select(member => member.Id).ToArray());
        }
コード例 #17
0
 protected override bool CreateTeam(TeamModel team)
 {
     return _repo.Create(team);
 }
コード例 #18
0
        private void UpdateTeams()
        {
            foreach (var team in Teams.Select(x => new { x.Id, Name = x.Name }).Where(x => !ActiveDirectorySettings.TeamNameToGroupNameMapping.Keys.Contains(x.Name, StringComparer.OrdinalIgnoreCase)))
            {
                Teams.Remove(team.Id);
            }

            if(MembershipService == null)
                MembershipService = new ADMembershipService();

            using (PrincipalContext principalContext = new PrincipalContext(ContextType.Domain, ActiveDirectorySettings.DefaultDomain))
            {
                foreach (string teamName in ActiveDirectorySettings.TeamNameToGroupNameMapping.Keys)
                {
                    try
                    {
                        using (GroupPrincipal group = GroupPrincipal.FindByIdentity(principalContext, IdentityType.Name, ActiveDirectorySettings.TeamNameToGroupNameMapping[teamName]))
                        {
                            TeamModel teamModel = new TeamModel() {
                                Id = group.Guid.Value,
                                Description = group.Description,
                                Name = teamName,
                                Members = group.GetMembers(true).Select(x => MembershipService.GetUserModel(x.Guid.Value)).ToArray()
                            };
                            if (teamModel != null)
                            {
                                Teams.AddOrUpdate(teamModel);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        LogException(ex);
                    }
                }
            }
        }
コード例 #19
0
        public void TeamCanBeUpdatedToChangeName()
        {
            var teamModel = new TeamModel { Name = "Team1", Description = "Test Team" };
            CreateTeam(teamModel);

            teamModel.Name = "SonOfTeam1";
            _repo.Update(teamModel);

            Assert.AreEqual("SonOfTeam1", _repo.GetAllTeams().Single().Name);
        }
コード例 #20
0
 protected abstract void UpdateTeam(TeamModel team);
コード例 #21
0
 protected override bool CreateTeam(TeamModel team)
 {
     team.Id = Guid.NewGuid();
     ADBackend.Instance.Teams.Add(team);
     return true;
 }
コード例 #22
0
        public void Update(TeamModel model)
        {
            if (model == null) throw new ArgumentException("team");
            if (model.Name == null) throw new ArgumentException("name");

            using (var db = CreateContext())
            {
                var team = db.Teams.FirstOrDefault(i => i.Id == model.Id);
                if (team != null)
                {
                    team.Name = model.Name;
                    team.Description = model.Description;
                    team.Users.Clear();
                    if (model.Members != null)
                    {
                        AddMembers(model.Members.Select(x => x.Id), team, db);
                    }
                    db.SaveChanges();
                }
            }
        }
コード例 #23
0
 private TeamDetailModel ConvertTeamModel(TeamModel model)
 {
     return model == null ? null : new TeamDetailModel
     {
         Name = model.Name,
         Description = model.Description,
         Members = model.Members,
         Repositories = model.Repositories,
     };
 }
コード例 #24
0
 private void AddTeamToRepo(Guid repoId, TeamModel team)
 {
     UpdateRepo(repoId, repo => repo.Teams = new[] { team });
 }
コード例 #25
0
 protected abstract bool CreateTeam(TeamModel team);
コード例 #26
0
        public void Update(TeamModel model)
        {
            if (model == null) throw new ArgumentException("team");
            if (model.Name == null) throw new ArgumentException("name");

            using (var db = new DataEntities())
            {
                var team = db.Team.FirstOrDefault(i => i.Name == model.Name);
                if (team != null)
                {
                    team.Description = model.Description;
                    team.Members.Clear();
                    if (model.Members != null)
                    {
                        AddMembers(model.Members, team, db);
                    }
                    db.SaveChanges();
                }
            }
        }
コード例 #27
0
 private TeamDetailModel ConvertDetailTeamModel(TeamModel model)
 {
     return model == null ? null : new TeamDetailModel
     {
         Id = model.Id,
         Name = model.Name,
         Description = model.Description,
         Members = model.Members.ToArray(),
         Repositories = RepositoryRepository.GetTeamRepositories(new[] { model.Id }).ToArray(),
         IsReadOnly = MembershipService.IsReadOnly()
     };
 }
コード例 #28
0
 protected override TeamModel AddTeam()
 {
     var newTeam = new TeamModel { Name = "Team1"};
     ADBackend.Instance.Teams.Add(newTeam);
     return newTeam;
 }
コード例 #29
0
 public void Update(TeamModel team)
 {
     throw new NotImplementedException();
 }