示例#1
0
        public ActionResult GetData()
        {
            var data         = new Data();
            var mapLocations = MapLocationList.LoadActive();

            foreach (var loc in mapLocations)
            {
                Location location = new Location()
                {
                    hoverText = loc.Title + " (" + loc.Dates + ")", title = loc.Title.HtmlEncode(), location = loc.LocationName.HtmlEncode(), address = loc.LocationAddress.HtmlEncode(), latitude = loc.Latitude.Value, longitude = loc.Longitude.Value, dates = loc.Dates.HtmlEncode(), startTime = Fmt.Time(loc.StartTime), link = loc.LinkUrl, html = loc.MoreInfoTextHtml.FmtHtmlText(), regionID = loc.MapRegionID ?? 0, eventType = loc.EventType
                };
                data.locations.Add(location);
            }
            var regions = MapRegionList.Load(new Sql("where exists (select * from maplocation where maplocation.mapregionid=mapregion.mapregionid) order by mapregionID"));

            foreach (var reg in regions)
            {
                data.regions.Add(new Region()
                {
                    regionID = reg.MapRegionID, title = reg.Title.HtmlEncode()
                });
            }
            var    serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
            string script     = "var data = " + serializer.Serialize(data);

            return(JavaScript(script));
        }