public async Task <List <TeamStandings> > GetStandings(int year) { var manualMapper = new ManualMapService(); //figure out what year of the 3 year group we are in then make api calls based on that //year 1 is a 1 year 2 is a 2 year 3 is a 0 var modYear = year % 3; var yearArr = GetThreeYearArray(modYear, year); var res1 = await _api.GetStandings(yearArr[0]); MflStandingsParent res2 = null; MflStandingsParent res3 = null; List <MflFranchiseStandings> franchiseListYr2 = null; List <MflFranchiseStandings> franchiseListYr3 = null; try { res2 = await _api.GetStandings(yearArr[1]); } catch (Exception) { /* ignore */ } try { res3 = await _api.GetStandings(yearArr[2]); } catch (Exception) { } var franchiseListYr1 = res1.LeagueStandings.Franchise; if (res2?.LeagueStandings != null) { franchiseListYr2 = res2.LeagueStandings.Franchise; } if (res3?.LeagueStandings != null) { franchiseListYr3 = res3.LeagueStandings.Franchise; } if (res2?.LeagueStandings == null) { return(manualMapper.MapOneYearStandings(franchiseListYr1)); } if (res3?.LeagueStandings == null) { return(manualMapper.MapTwoYearStandings(franchiseListYr1, franchiseListYr2)); } return(manualMapper.MapThreeYearStandings(franchiseListYr1, franchiseListYr2, franchiseListYr3)); }
public async Task <List <MflFranchiseStandings> > GetFranchiseStandings() { return((await _mfl.GetStandings(_thisYear)).LeagueStandings.Franchise .OrderBy(tm => Int32.Parse(tm.vp)) .ThenBy(tm => Decimal.Parse(tm.pf)).ToList()); }