public IEnumerable <ClubDto> GetAllClubs() { List <ClubDto> clubs = new List <ClubDto>(); var allClubsFromdb = _clubRepository.GetAll().ToList(); allClubsFromdb.ForEach(c => clubs.Add(new ClubDto() { ClubId = c.ClubId, ClubName = c.ClubName, Contact = c.Contact, LimitDateChild = c.LimitDateChild, Location = c.Location, NumberOfCoach = c.NumberOfCoach })); return(clubs); }
Task <IEnumerable <Club> > IRequestHandler <GetClubs, IEnumerable <Club> > .Handle(GetClubs request, CancellationToken cancellationToken) { return(clubRepository.GetAll(cancellationToken)); }
public IEnumerable <Club> GetClubs() { var clubs = clubRepository.GetAll(); return(clubs); }
public IEnumerable <Club> GetAll() { return(_clubRepo.GetAll()); }
public IHttpActionResult Get() { return(Json(clubRepository.GetAll())); }
/** * Search for clubs based on the search criteria * Only gets neccessary club info based on the search criteria * Sorts the list based on Match Percentage and returns the list */ public List <Club> HandleClubSearchAlgorithm(ClubSearchCriteria criterias, int id) { string sql = ""; string sqlPreference = ""; string sqlValue = ""; string sqlSeason = ""; List <Club> clubs = new List <Club>(); // If no criteria is selected all clubs is returned with season match // Since no criteria is selected, all clubs match 100% if (criterias.Country == null && criterias.League == null && criterias.Position == null && criterias.PreferencesList.Count == 0 && criterias.ValuesList.Count == 0) { string seasonSql = ""; if (criterias.Season == "Current year") { seasonSql = "and jp.season = 'Current year'"; } else if (criterias.Season == "Next year") { seasonSql = "and jp.season = 'Next year'"; } return((List <Club>)_clubRepos.GetAll(seasonSql)); } // Country, league and position is a must-match when selected // Get all clubs with matching league, country and/or position if (criterias.Country != null || criterias.League != null || criterias.Position != null) { sql += GetSeasonSql(criterias); if (criterias.League != null) { sql += " and c.league = '" + criterias.League + "' and isAvailable = 1 "; } if (criterias.Country != null) { sql += " and c.country = '" + criterias.Country + "' and isAvailable = 1 "; } if (criterias.Position != null) { sql += " and jp.position = '" + criterias.Position + "' and isAvailable = 1 "; } clubs = _clubRepos.GetBySearchCriteria(sql).ToList(); } // If Country, League and Position is not selected as a criteria // We continue to match with the 'less important' criterias // If only preference, season and value is selected else if (criterias.PreferencesList.Count > 0 && criterias.ValuesList.Count > 0) { sqlPreference = GetPreferenceSql(criterias); sqlValue = GetValueSql(criterias); sqlSeason = GetSeasonSql(criterias); clubs = _clubRepos.GetBySearchCriteriaWithJobPositionPreferenceValue(sqlPreference, sqlValue, sqlSeason).ToList(); } // If only season and value is selected else if (criterias.ValuesList.Count > 0) { sqlValue = GetValueSql(criterias); sqlSeason = GetSeasonSql(criterias); clubs = _clubRepos.GetBySearchCriteriaWithJobPoisitionValue(sqlValue, sqlSeason).ToList(); } // If only season and preference is selected else if (criterias.PreferencesList.Count > 0) { sqlPreference = GetPreferenceSql(criterias); sqlSeason = GetSeasonSql(criterias); clubs = _clubRepos.GetBySearchCriteriaWithJobPoisitionPreference(sqlPreference, sqlSeason).ToList(); } // If only preference and value is selected else if (criterias.PreferencesList.Count > 0 && criterias.ValuesList.Count > 0) { sqlPreference = GetPreferenceSql(criterias); sqlValue = GetValueSql(criterias); sqlSeason = GetSeasonSql(criterias); clubs = _clubRepos.GetBySearchCriteriaWithJobPositionPreferenceValue(sqlPreference, sqlValue, sqlSeason).ToList(); } // When the clubs list is build it is ready to be sorted by match percentage // Since we match player with open job positions, we need to get the player first Player player = _playerRepos.GetById(id); // Calculate match percentage, sort by match percentage and return the list clubs = CalculateCriteriaMatchPercentage(clubs, criterias, player); SortListByPercentage sort = new SortListByPercentage(); clubs.Sort(sort.CompareClub); return(clubs); }