public ChangeResult RemoveTeamPlayer(Guid playerId) { //remove player from lineup, then from the actual team var result = TeamPlayerLineup.Remove(TeamId, playerId); if (result.IsSuccess) { result = PlayerTeam.Remove(playerId, TeamId); } return(result); }
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); }