/// <summary> /// Converts the age filter object to the appropriate string. /// </summary> /// <param name="age">The age filter.</param> /// <returns>The appropriate string for the specified filter.</returns> public static String AgeFilterToString(AgeFilter age) { switch (age) { case AgeFilter.One: return("0-24"); case AgeFilter.Two: return("age=25-34"); case AgeFilter.Three: return("35-44"); case AgeFilter.Four: return("45-54"); case AgeFilter.Five: return("55-64"); case AgeFilter.Six: return("65_plus"); default: return(String.Empty); } }
/// <summary> /// Gets the leaderboard of a segment. You can use various filters to filter the data. /// Some of the filters require a Strava Premium account! /// </summary> /// <param name="segmentId">The Strava segment Id.</param> /// <param name="weight">The weight class used to filter the leaderboard.</param> /// <param name="age">The age group used to filter the leaderboard.</param> /// <param name="time">The time used to filter the leaderboard.</param> /// <param name="gender">The gender used to filter the leaderboard.</param> /// <returns>The leaderboard filtered by gender.</returns> public async Task<Leaderboard> GetSegmentLeaderboardAsync(String segmentId, WeightFilter weight, AgeFilter age, TimeFilter time, GenderFilter gender) { int page = 1; //Create one dummy request to get the number of entries. Leaderboard request = await GetSegmentLeaderboardAsync(segmentId, weight, age, time, gender, 1, 1); int totalAthletes = request.EntryCount; Leaderboard leaderboard = new Leaderboard { EffortCount = request.EffortCount, EntryCount = request.EntryCount }; while ((page - 1) * 200 < totalAthletes) { Leaderboard l = await GetSegmentLeaderboardAsync(segmentId, weight, age, time, gender, page++, 200); foreach (LeaderboardEntry entry in l.Entries) { leaderboard.Entries.Add(entry); } } return leaderboard; }
public static void Main() { Student[] myClass = { new Student("Ivan", "Mihailov", 19), new Student("Ivan", "Ivanov", 25), new Student("Ivan", "Dimitrov", 18), new Student("Ivan", "Stoianov", 36) }; AgeFilter myFilter = new AgeFilter(myClass); myFilter.ShowFilterdClass(); }
public static IFilter GetFilter(eFilter i_Filter, string i_Text) { IFilter filter; if (i_Filter == eFilter.AGE) { filter = new AgeFilter(i_Text); } else { filter = new GenderFilter(i_Text); } return(filter); }
internal void FillFriendsResultOnDataTable(ICollection <User> i_AllFriendsFromStartPoint) { dataGridFriendsResult.Controls.Clear(); bindingSourceRideFriendsGrid.DataSource = i_AllFriendsFromStartPoint; int counter = 0; foreach (User currentUser in i_AllFriendsFromStartPoint) { DataGridViewTextBoxCell cell = new DataGridViewTextBoxCell() { Value = AgeFilter.GetAgeFromUserBirthday(currentUser.Birthday) }; dataGridFriendsResult.Rows[counter].Cells[AgeColumn.Index] = cell; counter++; } }
/// <summary> /// Converts the age filter object to the appropriate string. /// </summary> /// <param name="age">The age filter.</param> /// <returns>The appropriate string for the specified filter.</returns> public static String AgeFilterToString(AgeFilter age) { switch (age) { case AgeFilter.One: return "0-24"; case AgeFilter.Two: return "age=25-34"; case AgeFilter.Three: return "35-44"; case AgeFilter.Four: return "45-54"; case AgeFilter.Five: return "55-64"; case AgeFilter.Six: return "65_plus"; default: return String.Empty; } }
private List <string> GetAgeLimitList(AgeFilter ageFilter) { var limitList = new List <string>(); if (ageFilter == null || ageFilter.All) { return(limitList); } if (ageFilter.After05) { limitList.Add(" BirthDate>='2005-01-01' "); } if (ageFilter.After00) { limitList.Add(" BirthDate>='2000-01-01' And BirthDate<'2005-01-01' "); } if (ageFilter.After95) { limitList.Add(" BirthDate>='1995-01-01' And BirthDate<'2000-01-01' "); } if (ageFilter.After90) { limitList.Add(" BirthDate>='1990-01-01' And BirthDate<'1995-01-01' "); } if (ageFilter.After85) { limitList.Add(" BirthDate>='1985-01-01' And BirthDate<'1990-01-01' "); } if (ageFilter.After80) { limitList.Add(" BirthDate>='1980-01-01' And BirthDate<'1985-01-01' "); } if (ageFilter.Before80) { limitList.Add(" BirthDate<'1980-01-01' "); } return(limitList); }
/// <summary> /// Gets the leaderboard of a segment. You can use various filters to filter the data. /// Some of the filters require a Strava Premium account! /// </summary> /// <param name="segmentId">The Strava segment Id.</param> /// <param name="weight">The weight class used to filter the leaderboard.</param> /// <param name="age">The age group used to filter the leaderboard.</param> /// <param name="time">The time used to filter the leaderboard.</param> /// <param name="gender">The gender used to filter the leaderboard.</param> /// <param name="page">The result page.</param> /// <param name="perPage">Efforts shown per page.</param> /// <returns>The leaderboard filtered by gender.</returns> public async Task<Leaderboard> GetSegmentLeaderboardAsync(String segmentId, WeightFilter weight, AgeFilter age, TimeFilter time, GenderFilter gender, int page, int perPage) { bool useGender = false; bool useTime = false; bool useAge = false; bool useWeight = false; String genderFilter = String.Empty; String timeFilter = String.Empty; String ageFilter = String.Empty; String weightFilter = String.Empty; if (!String.IsNullOrEmpty(StringConverter.GenderFilterToString(gender))) { genderFilter = String.Format("gender={0}", StringConverter.GenderFilterToString(gender)); useGender = true; } if (!String.IsNullOrEmpty(StringConverter.TimeFilterToString(time))) { timeFilter = String.Format("date_range={0}", StringConverter.TimeFilterToString(time)); useTime = true; } if (!String.IsNullOrEmpty(StringConverter.AgeFilterToString(age))) { ageFilter = String.Format("age_group={0}", StringConverter.AgeFilterToString(age)); useAge = true; } if (!String.IsNullOrEmpty(StringConverter.WeightFilterToString(weight))) { weightFilter = String.Format("weight_class={0}", StringConverter.WeightFilterToString(weight)); useWeight = true; } String getUrl = String.Format("{0}/{1}/leaderboard?{2}&{3}&{4}&{5}&page={6}&per_page={7}&access_token={8}", Endpoints.Leaderboard, segmentId, useGender ? genderFilter : String.Empty, useTime ? timeFilter : String.Empty, useAge ? ageFilter : String.Empty, useWeight ? weightFilter : String.Empty, page, perPage, Authentication.AccessToken ); String json = await WebRequest.SendGetAsync(new Uri(getUrl)); return Unmarshaller<Leaderboard>.Unmarshal(json); }
/// <summary> /// Gets the leaderboard of a segment. You can use various filters to filter the data. /// Some of the filters require a Strava Premium account! /// </summary> /// <param name="segmentId">The Strava segment Id.</param> /// <param name="weight">The weight class used to filter the leaderboard.</param> /// <param name="age">The age group used to filter the leaderboard.</param> /// <param name="time">The time used to filter the leaderboard.</param> /// <param name="gender">The gender used to filter the leaderboard.</param> /// <param name="page">The result page.</param> /// <param name="perPage">Efforts shown per page.</param> /// <returns>The leaderboard filtered by gender.</returns> public async Task <Leaderboard> GetSegmentLeaderboardAsync(string segmentId, WeightFilter weight, AgeFilter age, TimeFilter time, GenderFilter gender, int page, int perPage) { bool useGender = false; bool useTime = false; bool useAge = false; bool useWeight = false; string genderFilter = string.Empty; string timeFilter = string.Empty; string ageFilter = string.Empty; string weightFilter = string.Empty; if (!string.IsNullOrEmpty(StringConverter.GenderFilterToString(gender))) { genderFilter = string.Format("gender={0}", StringConverter.GenderFilterToString(gender)); useGender = true; } if (!string.IsNullOrEmpty(StringConverter.TimeFilterToString(time))) { timeFilter = string.Format("date_range={0}", StringConverter.TimeFilterToString(time)); useTime = true; } if (!string.IsNullOrEmpty(StringConverter.AgeFilterToString(age))) { ageFilter = string.Format("age_group={0}", StringConverter.AgeFilterToString(age)); useAge = true; } if (!string.IsNullOrEmpty(StringConverter.WeightFilterToString(weight))) { weightFilter = string.Format("weight_class={0}", StringConverter.WeightFilterToString(weight)); useWeight = true; } string getUrl = string.Format("{0}/{1}/leaderboard?{2}&{3}&{4}&{5}&page={6}&per_page={7}&access_token={8}", Endpoints.Leaderboard, segmentId, useGender ? genderFilter : string.Empty, useTime ? timeFilter : string.Empty, useAge ? ageFilter : string.Empty, useWeight ? weightFilter : string.Empty, page, perPage, AuthSettings.ScopeAccessToken ); string json = await StravaUWP.Helper.HttpHelper.GetRequestAsync(getUrl);; return(Unmarshaller <Leaderboard> .Unmarshal(json)); }
/// <summary> /// Gets the leaderboard of a segment. You can use various filters to filter the data. /// Some of the filters require a Strava Premium account! /// </summary> /// <param name="segmentId">The Strava segment Id.</param> /// <param name="following">The leaderboard only shows athletes you're following.</param> /// <param name="weight">The weight class used to filter the leaderboard.</param> /// <param name="age">The age group used to filter the leaderboard.</param> /// <param name="time">The time used to filter the leaderboard.</param> /// <param name="gender">The gender used to filter the leaderboard.</param> /// <returns>The leaderboard filtered by gender.</returns> public Leaderboard GetSegmentLeaderboard(string segmentId, bool following, WeightFilter weight, AgeFilter age, TimeFilter time, GenderFilter gender) { int page = 1; //Create one dummy request to get the number of entries. Leaderboard request = GetSegmentLeaderboard(segmentId, following, weight, age, time, gender, 1, 1); int totalAthletes = request.EntryCount; Leaderboard leaderboard = new Leaderboard { EffortCount = request.EffortCount, EntryCount = request.EntryCount }; while ((page - 1) * 200 < totalAthletes) { Leaderboard l = GetSegmentLeaderboard(segmentId, following, weight, age, time, gender, page++, 200); foreach (LeaderboardEntry entry in l.Entries) { leaderboard.Entries.Add(entry); } } return(leaderboard); }
public async Task <Leaderboard> GetSegmentLeaderboardAsync(string segmentId, int clubId, WeightFilter weight, AgeFilter age, TimeFilter time, GenderFilter gender) { int page = 1; Leaderboard request = await GetSegmentLeaderboardAsync(segmentId, clubId, weight, age, time, gender, 1, 1); int totalAthletes = request.EntryCount; Leaderboard leaderboard = new Leaderboard { EffortCount = request.EffortCount, EntryCount = request.EntryCount }; while ((page - 1) * 200 < totalAthletes) { foreach (LeaderboardEntry entry in (await GetSegmentLeaderboardAsync(segmentId, clubId, weight, age, time, gender, page++, 200)).Entries) { leaderboard.Entries.Add(entry); } } return(leaderboard); }
public Leaderboard GetSegmentLeaderboard(string segmentId, bool following, WeightFilter weight, AgeFilter age, TimeFilter time, GenderFilter gender, int page, int perPage) { bool flag = false; bool flag2 = false; bool flag3 = false; bool flag4 = false; string text = string.Empty; string text2 = string.Empty; string text3 = string.Empty; string text4 = string.Empty; if (!string.IsNullOrEmpty(StringConverter.GenderFilterToString(gender))) { text = $"gender={StringConverter.GenderFilterToString(gender)}"; flag = true; } if (!string.IsNullOrEmpty(StringConverter.TimeFilterToString(time))) { text2 = $"date_range={StringConverter.TimeFilterToString(time)}"; flag2 = true; } if (!string.IsNullOrEmpty(StringConverter.AgeFilterToString(age))) { text3 = $"age_group={StringConverter.AgeFilterToString(age)}"; flag3 = true; } if (!string.IsNullOrEmpty(StringConverter.WeightFilterToString(weight))) { text4 = $"weight_class={StringConverter.WeightFilterToString(weight)}"; flag4 = true; } string uriString = string.Format("{0}/{1}/leaderboard?{2}&{3}&{4}&{5}&following={6}&page={7}&per_page={8}&access_token={9}", "https://www.strava.com/api/v3/segments", segmentId, flag ? text : string.Empty, flag2 ? text2 : string.Empty, flag3 ? text3 : string.Empty, flag4 ? text4 : string.Empty, following, page, perPage, Authentication.AccessToken); string json = WebRequest.SendGet(new Uri(uriString)); return(Unmarshaller <Leaderboard> .Unmarshal(json)); }
public async Task <Leaderboard> GetSegmentLeaderboardAsync(string segmentId, WeightFilter weight, AgeFilter age, TimeFilter time, GenderFilter gender, int page, int perPage) { bool useGender = false; bool useTime = false; bool useAge = false; bool useWeight = false; string genderFilter = string.Empty; string timeFilter = string.Empty; string ageFilter = string.Empty; string weightFilter = string.Empty; if (!string.IsNullOrEmpty(StringConverter.GenderFilterToString(gender))) { genderFilter = $"gender={StringConverter.GenderFilterToString(gender)}"; useGender = true; } if (!string.IsNullOrEmpty(StringConverter.TimeFilterToString(time))) { timeFilter = $"date_range={StringConverter.TimeFilterToString(time)}"; useTime = true; } if (!string.IsNullOrEmpty(StringConverter.AgeFilterToString(age))) { ageFilter = $"age_group={StringConverter.AgeFilterToString(age)}"; useAge = true; } if (!string.IsNullOrEmpty(StringConverter.WeightFilterToString(weight))) { weightFilter = $"weight_class={StringConverter.WeightFilterToString(weight)}"; useWeight = true; } string getUrl = string.Format("{0}/{1}/leaderboard?{2}&{3}&{4}&{5}&page={6}&per_page={7}&access_token={8}", "https://www.strava.com/api/v3/segments", segmentId, useGender ? genderFilter : string.Empty, useTime ? timeFilter : string.Empty, useAge ? ageFilter : string.Empty, useWeight ? weightFilter : string.Empty, page, perPage, Authentication.AccessToken); return(Unmarshaller <Leaderboard> .Unmarshal(await WebRequest.SendGetAsync(new Uri(getUrl)))); }
public Leaderboard GetSegmentLeaderboard(string segmentId, bool following, WeightFilter weight, AgeFilter age, TimeFilter time, GenderFilter gender) { int num = 1; Leaderboard segmentLeaderboard = GetSegmentLeaderboard(segmentId, following, weight, age, time, gender, 1, 1); int entryCount = segmentLeaderboard.EntryCount; Leaderboard leaderboard = new Leaderboard { EffortCount = segmentLeaderboard.EffortCount, EntryCount = segmentLeaderboard.EntryCount }; while ((num - 1) * 200 < entryCount) { Leaderboard segmentLeaderboard2 = GetSegmentLeaderboard(segmentId, following, weight, age, time, gender, num++, 200); foreach (LeaderboardEntry entry in segmentLeaderboard2.Entries) { leaderboard.Entries.Add(entry); } } return(leaderboard); }
/// <summary> /// Gets the leaderboard of a segment. You can use various filters to filter the data. /// Some of the filters require a Strava Premium account! /// </summary> /// <param name="segmentId">The Strava segment Id.</param> /// <param name="following">The leaderboard only shows athletes you're following.</param> /// <param name="weight">The weight class used to filter the leaderboard.</param> /// <param name="age">The age group used to filter the leaderboard.</param> /// <param name="time">The time used to filter the leaderboard.</param> /// <param name="gender">The gender used to filter the leaderboard.</param> /// <param name="page">The result page.</param> /// <param name="perPage">Efforts shown per page.</param> /// <returns>The leaderboard filtered by gender.</returns> public Leaderboard GetSegmentLeaderboard(string segmentId, bool following, WeightFilter weight, AgeFilter age, TimeFilter time, GenderFilter gender, int page, int perPage) { bool useGender = false; bool useTime = false; bool useAge = false; bool useWeight = false; string genderFilter = string.Empty; string timeFilter = string.Empty; string ageFilter = string.Empty; string weightFilter = string.Empty; if (!string.IsNullOrEmpty(StringConverter.GenderFilterToString(gender))) { genderFilter = string.Format("gender={0}", StringConverter.GenderFilterToString(gender)); useGender = true; } if (!string.IsNullOrEmpty(StringConverter.TimeFilterToString(time))) { timeFilter = string.Format("date_range={0}", StringConverter.TimeFilterToString(time)); useTime = true; } if (!string.IsNullOrEmpty(StringConverter.AgeFilterToString(age))) { ageFilter = string.Format("age_group={0}", StringConverter.AgeFilterToString(age)); useAge = true; } if (!string.IsNullOrEmpty(StringConverter.WeightFilterToString(weight))) { weightFilter = string.Format("weight_class={0}", StringConverter.WeightFilterToString(weight)); useWeight = true; } string getUrl = string.Format("{0}/{1}/leaderboard?{2}&{3}&{4}&{5}&following={6}&page={7}&per_page={8}&access_token={9}", Endpoints.Leaderboard, segmentId, useGender ? genderFilter : string.Empty, useTime ? timeFilter : string.Empty, useAge ? ageFilter : string.Empty, useWeight ? weightFilter : string.Empty, following, page, perPage, Authentication.AccessToken ); string json = WebRequest.SendGet(new Uri(getUrl)); return(Unmarshaller <Leaderboard> .Unmarshal(json)); }