public ActionResult GoogleMapsPostLocations(GoogleMapsLocationsModel model) { DateTime? fromDate = this.TryParseDateTime(model.DateFrom); DateTime? toDate = this.TryParseDateTime(model.DateTo); IList<LocationInfo> locations = this._repositoryService.GetTopLocations(fromDate: fromDate, toDate: toDate); this.PrepareGoogleMapsLocationsModel(model, locations); return View(model); }
public ActionResult GoogleMapsPostLocations() { DateTime fromDate = new DateTime(2013, 1, 1); DateTime toDate = new DateTime(2014, 1, 1); GoogleMapsLocationsModel model = new GoogleMapsLocationsModel() { DateFrom = fromDate.ToShortDateString(), DateTo = toDate.ToShortDateString() }; IList<LocationInfo> locations = this._repositoryService.GetTopLocations(fromDate: fromDate, toDate: toDate); this.PrepareGoogleMapsLocationsModel(model, locations); return View(model); }
private void PrepareGoogleMapsLocationsModel(GoogleMapsLocationsModel model, IList<LocationInfo> locations) { model = model ?? new GoogleMapsLocationsModel(); if (!locations.IsEmpty()) { /// filter only locations with coordinates locations = locations.Where(x => x.Longitude.HasValue && x.Latitude.HasValue).ToList(); foreach (LocationInfo li in locations) { li.Name = HttpUtility.JavaScriptStringEncode(li.Name); li.Description = HttpUtility.JavaScriptStringEncode(li.Description); } model.Locations = locations; } }