public void FillAvailablePlayers() { PlayersFiltered = new List <Models.Player>(); AllPlayers = new List <Models.Player>(); List <Guid> teamPlayerIds = PlayerTeam.GetTeamPlayers(TeamId).Select(y => y.PlayerId).ToList(); foreach (var player in Player.GetPlayers().OrderBy(y => y.LastName).ThenBy(y => y.Name)) { if (!teamPlayerIds.Contains(player.PlayerId)) { AllPlayers.Add(new Models.Player(player)); } } PlayersFiltered.AddRange(AllPlayers); }
public void AddUpdatePlayerTeamTest() { Guid seedTeamId = SeedTeam(); Guid seedPlayerId = SeedPlayer(); PlayerTeamDto dto = new PlayerTeamDto() { PlayerId = seedPlayerId, TeamId = seedTeamId }; var addResult = PlayerTeamService.AddNew(dto); Assert.IsTrue(addResult.IsSuccess); var playerTeam = PlayerTeamService.GetPlayerTeam(seedTeamId, seedPlayerId); Assert.IsNotNull(playerTeam); Assert.AreEqual(seedTeamId, playerTeam.TeamId); Assert.AreEqual(seedPlayerId, playerTeam.PlayerId); Assert.IsFalse(playerTeam.PlayerTeamId == Guid.Empty); dto.PlayerTeamId = playerTeam.PlayerTeamId; var updateResult = PlayerTeamService.Update(dto); Assert.IsTrue(updateResult.IsSuccess); var teamPlayers = PlayerTeamService.GetTeamPlayers(seedTeamId); Assert.IsTrue(teamPlayers.Count >= 1); var teamPlayerInfos = PlayerTeamService.GetTeamPlayerInformations(seedTeamId); Assert.IsTrue(teamPlayerInfos.Count >= 1); Assert.IsNotNull(teamPlayerInfos.FirstOrDefault().Name); var removeResult = PlayerTeamService.Remove(seedPlayerId, seedTeamId); Assert.IsTrue(removeResult.IsSuccess); playerTeam = PlayerTeamService.GetPlayerTeam(seedTeamId, seedPlayerId); Assert.IsNull(playerTeam); DeleteSeededTeam(seedTeamId); DeleteSeededPlayer(seedPlayerId); }