public void FillPlayers()
        {
            TeamPlayers = new ObservableCollection <Models.Player>();

            foreach (var player in PlayerTeam.GetTeamPlayerInformations(TeamId).OrderBy(y => y.LastName).ThenBy(y => y.Name))
            {
                TeamPlayers.Add(new Models.Player(player));
            }
        }
        public void FillPlayersToAddToLineup()
        {
            Players = new List <Models.Player>();

            List <Guid> playerIdsInLineup = TeamPlayerLineup.GetTeamLineup(TeamId)
                                            .Where(z => !z.DeleteDate.HasValue)
                                            .Select(y => y.PlayerId).ToList();

            foreach (var player in PlayerTeam.GetTeamPlayerInformations(TeamId))
            {
                if (!playerIdsInLineup.Contains(player.PlayerId))
                {
                    Players.Add(new Models.Player(player));
                }
            }
        }
        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);
        }
        public void FillBatters()
        {
            Batters = new List <Models.Player>();
            foreach (var item in TeamPlayerLineup.GetTeamSortedBattingOrderPlayers(TeamId))
            {
                Batters.Add(new Models.Player(item));
            }

            if (Batters.Count == 0)
            {
                //add all players on the team
                foreach (var item in PlayerTeam.GetTeamPlayerInformations(TeamId))
                {
                    Batters.Add(new Models.Player(item));
                }
                SaveLineup();
            }
        }