public Player GetPlayerByName(string name) { Player player = database.Players.Where(x => x.Username.ToLower() == name.ToLower()).FirstOrDefault(); IRequestsRepository repository; // Strategy pattern if (player == null) { repository = new ExternalRequestRepository(); } else { repository = new InternalRequestRepository(); } return(repository.GetPlayerByName(name)); }
public IEnumerable <Match> GetMatchesByPlayerId(long id) { Player player = database.Players.Where(x => x.Id == id).FirstOrDefault(); // Console.WriteLine("Player: " + player.ToString()); IRequestsRepository repository; // Strategy pattern if (player == null || RefreshRequired(player.lastExternalApiCall)) { repository = new ExternalRequestRepository(); } else { repository = new InternalRequestRepository(); } return(repository.GetMatchesByPlayerId(id)); }