public JsonResult GetExternalInfos(int id) { var backOffice = new Business.BackOffice(); Location location = backOffice.Locations.FirstOrDefault(l => l.Id == id); FoursquareVenue cacheItemFoursquare = null; if (!string.IsNullOrWhiteSpace(location.FoursquareID)) { string cacheKeyFoursquare = "foursquare-venue-" + location.FoursquareID; cacheItemFoursquare = (FoursquareVenue)WebCache.Get(cacheKeyFoursquare); if (cacheItemFoursquare == null) { cacheItemFoursquare = new FoursquareVenue(location.FoursquareID); WebCache.Set(cacheKeyFoursquare, cacheItemFoursquare, 1440); // one day cache } } GoogleNearby cacheItemGoogle = null; string cacheKeyGoogle = "google-nearby-" + location.Id; cacheItemGoogle = (GoogleNearby)WebCache.Get(cacheKeyGoogle); if (cacheItemGoogle == null) { cacheItemGoogle = new GoogleNearby(location.Latitude, location.Longitude); WebCache.Set(cacheKeyGoogle, cacheItemGoogle, 1440); // one day cache } return(Json(new LocationExternal(cacheItemFoursquare, cacheItemGoogle), JsonRequestBehavior.AllowGet)); }
private void InitLocationsByCoordinate(GeoCoordinate coordinate, bool onlyOpen) { var backOffice = new Business.BackOffice(); int zone = 0; int notMatchableBarCount = 0; while (Locations.Count < _findNumberBarFromLocations && notMatchableBarCount < backOffice.Locations.Count) { notMatchableBarCount = 0; zone += 200; foreach (Location location in backOffice.Locations) { var locationCoordinate = new GeoCoordinate(location.Latitude, location.Longitude); if (location.IsValid && !Locations.Contains(location) && (!onlyOpen || onlyOpen && location.IsOpenNow)) { if (coordinate.GetDistanceTo(locationCoordinate) < zone) { Locations.Add(location); } } else { notMatchableBarCount++; } } } }
public JsonResult GetExternalInfos(int id) { var backOffice = new Business.BackOffice(); Location location = backOffice.Locations.FirstOrDefault(l => l.Id == id); FoursquareVenue cacheItemFoursquare = null; if (!string.IsNullOrWhiteSpace(location.FoursquareID)) { string cacheKeyFoursquare = "foursquare-venue-" + location.FoursquareID; cacheItemFoursquare = (FoursquareVenue)WebCache.Get(cacheKeyFoursquare); if (cacheItemFoursquare == null) { cacheItemFoursquare = new FoursquareVenue(location.FoursquareID); WebCache.Set(cacheKeyFoursquare, cacheItemFoursquare, 1440); // one day cache } } GoogleNearby cacheItemGoogle = null; string cacheKeyGoogle = "google-nearby-" + location.Id; cacheItemGoogle = (GoogleNearby)WebCache.Get(cacheKeyGoogle); if (cacheItemGoogle == null) { cacheItemGoogle = new GoogleNearby(location.Latitude, location.Longitude); WebCache.Set(cacheKeyGoogle, cacheItemGoogle, 1440); // one day cache } return Json(new LocationExternal(cacheItemFoursquare, cacheItemGoogle), JsonRequestBehavior.AllowGet); }
public SearchResultModel(int id) : this() { var backOffice = new Business.BackOffice(); foreach (Location location in backOffice.Locations) { if (location.Id == id && location.IsValid) { Locations.Add(location); } } }
public SearchResultModel(int id) : this() { var backOffice = new Business.BackOffice(); foreach (Location location in backOffice.Locations) { if (location.Id == id && location.IsValid) { Locations.Add(location); } } }
public JsonResult All() { var backOffice = new Business.BackOffice(); return(Json(backOffice.Locations, JsonRequestBehavior.AllowGet)); }
public JsonResult All() { var backOffice = new Business.BackOffice(); return Json(backOffice.Locations, JsonRequestBehavior.AllowGet); }
private void InitLocationsByCoordinate(GeoCoordinate coordinate, bool onlyOpen) { var backOffice = new Business.BackOffice(); int zone = 0; int notMatchableBarCount = 0; while (Locations.Count < _findNumberBarFromLocations && notMatchableBarCount < backOffice.Locations.Count) { notMatchableBarCount = 0; zone += 200; foreach (Location location in backOffice.Locations) { var locationCoordinate = new GeoCoordinate(location.Latitude, location.Longitude); if (location.IsValid && !Locations.Contains(location) && (!onlyOpen || onlyOpen && location.IsOpenNow)) { if (coordinate.GetDistanceTo(locationCoordinate) < zone) { Locations.Add(location); } } else { notMatchableBarCount++; } } } }