public IHttpActionResult Get(int id, int?unionId = null, int?leagueId = null) { User player = db.Users.FirstOrDefault(u => u.UserId == id && u.IsArchive == false && u.IsActive); if (player == null) { return(NotFound()); } if (unionId == null && leagueId != null) { LeagueRepo leagueRepo = new LeagueRepo(); League league = leagueRepo.GetById((int)leagueId); unionId = league != null ? league.UnionId : null; } int?seasonId = unionId != null?_seasonsRepo.GetLastSeasonByCurrentUnionId(unionId.Value) : (int?)null; PlayerProfileViewModel vm = PlayerService.GetPlayerProfile(player); var teamsRepo = new TeamsRepo(); vm.Teams = teamsRepo.GetPlayerPositions(id, seasonId); vm.FriendshipStatus = FriendsService.AreFriends(id, CurrUserId); if (User.Identity.IsAuthenticated) { vm.Friends = FriendsService.GetAllFanFriends(id, base.CurrUserId); } vm.Games = GamesService.GetPlayerGames(player.UserId, seasonId); GamesService.UpdateGameSets(vm.Games); return(Ok(vm)); }