public async Task <IActionResult> GetClosestCurrentReport(string lat, string lon) { // create new instances of bouyFinder and spotFinder classes BuoyFinder buoyFinder = new BuoyFinder(); SpotFinder spotFinder = new SpotFinder(); // get the closest beach by using the lat/long passed in by the user Beach closestSpot = spotFinder.FindSpot(lat, lon); // get a list of buoys that are close to the beach List <Buoy> matchingBuoys = buoyFinder.MatchBuoys(closestSpot.Latitude, closestSpot.Longtitude); // create empty list for hold current beach reports List <CurrentBeachReport> currentBeachReports = new List <CurrentBeachReport>(); // itterate through the list of buoys foreach (Buoy b in matchingBuoys) { // get report from current buoy CurrentReport currentReport = await MakeCurrentReport.GetAsync(b); // compile data from closestSpot object and currentReport object into // currentBeachReport object with contructor function CurrentBeachReport currentBeachReport = new CurrentBeachReport(closestSpot, currentReport); // add beach report object to list currentBeachReports.Add(currentBeachReport); } // return reports return(Ok(currentBeachReports)); }
public async Task <IActionResult> GetClosestFullReport(string lat, string lon) { BuoyFinder buoyFinder = new BuoyFinder(); SpotFinder spotFinder = new SpotFinder(); Beach closestSpot = spotFinder.FindSpot(lat, lon); List <Buoy> matchingBuoys = buoyFinder.MatchBuoys(closestSpot.Latitude, closestSpot.Longtitude); List <FullBeachReport> fullBeachReports = new List <FullBeachReport>(); foreach (Buoy b in matchingBuoys) { FullReport fullReport = await Make45DayReport.GetAsync(b); FullBeachReport fullBeachReport = new FullBeachReport(closestSpot, fullReport); fullBeachReports.Add(fullBeachReport); } return(Ok(fullBeachReports)); }