public virtual ActionResult ShowResults(double distance, double x, double y) { // Now, time to get results var marketFinder = new FindFarmerMarkets(); ViewBag.Distance = distance; List<ResultViewModel> markets = marketFinder.GetMarketsWithinRange(x, y, distance); return View(markets); }
// GET api/marketsearch?xloc=1.5&yloc=4.5&distance=5 // Returns all the markets that are within the specified distance from the provided location // distance is in meters public List<ResultViewModel> Get(double xloc, double yloc, double distance) { var marketFinder = new FindFarmerMarkets(); List<ResultViewModel> nearMarkets = marketFinder.GetMarketsWithinRange(xloc, yloc, distance); return nearMarkets; }
// GET api/marketsearch?xloc=1.5&yloc=4.5 // Returns the closest market to the listed location + distance // distance is in meters public ResultViewModel Get(double xloc, double yloc) { var marketFinder = new FindFarmerMarkets(); ResultViewModel closestMarket = marketFinder.GetClosestMarket(xloc, yloc); return closestMarket; }
// spreading this out from show results is a bit silly, mostly for experimental reasons public virtual ActionResult ShowSingleResult(double x, double y) { var marketFinder = new FindFarmerMarkets(); ResultViewModel market = marketFinder.GetClosestMarket(x, y); return View(market); }