public async Task <IActionResult> Get45DayBuoyData(string nbdcId) { // find requested buoy Buoy buoy = _context.Buoy.Single(b => b.NbdcId == nbdcId); // get report data for buoy FullReport fullReport = await Make45DayReport.GetAsync(buoy); // return report data return(Ok(fullReport)); }
public async Task <IActionResult> GetClosestFullReports(string lat, string lon, int spotCount) { SpotFinder spotFinder = new SpotFinder(); BuoyFinder buoyFinder = new BuoyFinder(); List <Buoy> matchedBuoys = new List <Buoy>(); List <FullBeachReport> fullBeachReport = new List <FullBeachReport>(); List <FullReport> matchedBuoyReports = new List <FullReport>(); List <SpotDistanceFromUser> spotsWithUserDistance = spotFinder.FindSpots(lat, lon, spotCount); foreach (SpotDistanceFromUser obj in spotsWithUserDistance) { string beachLat = obj.Beach.Latitude; string beachLon = obj.Beach.Longtitude; List <Buoy> matchingBuoys = buoyFinder.MatchBuoys(beachLat, beachLon); foreach (Buoy b in matchingBuoys) { matchedBuoys.Add(b); } } matchedBuoys = matchedBuoys.GroupBy(mb => mb.BuoyId).Select(mb => mb.First()).ToList(); foreach (Buoy b in matchedBuoys) { Console.WriteLine("hello"); FullReport fullReport = await Make45DayReport.GetAsync(b); Console.WriteLine("done"); matchedBuoyReports.Add(fullReport); } foreach (SpotDistanceFromUser obj in spotsWithUserDistance) { string beachLat = obj.Beach.Latitude; string beachLon = obj.Beach.Longtitude; List <Buoy> matchingBuoys = buoyFinder.MatchBuoys(beachLat, beachLon); foreach (FullReport r in matchedBuoyReports) { foreach (Buoy b in matchingBuoys) { if (r.NbdcId == b.NbdcId) { FullBeachReport report = new FullBeachReport(obj.Beach, r); fullBeachReport.Add(report); } } } } return(Ok(fullBeachReport)); }
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)); }
public async Task <IActionResult> GetSingleFullReport(int spotId) { BuoyFinder buoyFinder = new BuoyFinder(); Beach beach = _context.Beach.Single(b => b.BeachId == spotId); List <Buoy> matchingBuoys = buoyFinder.MatchBuoys(beach.Latitude, beach.Longtitude); List <FullBeachReport> fullBeachReports = new List <FullBeachReport>(); foreach (Buoy b in matchingBuoys) { FullReport fullReport = await Make45DayReport.GetAsync(b); FullBeachReport fullBeachReport = new FullBeachReport(beach, fullReport); fullBeachReports.Add(fullBeachReport); } return(Ok(fullBeachReports)); }