public ApiResult GetMapModel(ApiGetMapModel model) { var result = new ApiResult(); try { result.Success = true; result.Data = _prh.GetMapModel(model); } catch (Exception e) { result.Success = false; result.ErrorMessage = e.Message; } return(result); }
internal ApiMapsModel GetMapModel(ApiGetMapModel apiModel) { using (_db) { var sql = string.Format("SELECT * FROM {0} WHERE Alias = '{1}'", StaticHelper.GetMapsTableName(), apiModel.Alias); var model = _db.Query <NovicellMapBuilderMapsModel>(sql).FirstOrDefault(); if (model == null) { return(null); } var jss = new JavaScriptSerializer(); var apiResult = new ApiMapsModel { ApiKey = model.ApiKey, Center = model.Center.Split(',').Select(d => double.Parse(d, CultureInfo.InvariantCulture)).ToArray(), CenterOnMarker = model.CenterOnMarker, ClusterStyle = jss.Deserialize <List <ApiClusterStyleModel> >(model.ClusterStyle), DefaultIconStyleModel = jss.Deserialize <ApiDefaultIconStyleModel>(model.DefaultIconStyle), InfoWindowName = model.InfoWindowName, InfoWindowWidth = model.InfoWindowWidth, InitialZoom = model.InitialZoom, MaxZoom = model.MaxZoom, MinZoom = model.MinZoom, Nodes = GetNodes(model.DataId, model.InfoWindowName, apiModel.NodeIds, apiModel.TitleProperty, apiModel.CoordsProperty), Style = jss.Deserialize <List <ApiStylingModel> >(model.Style), UseClustering = model.UseClustering, UseGeoLocation = model.UseGeoLocation, UseInfoWindows = model.UseInfoWindows, Draggable = model.Draggable, UseZoomControl = model.UseZoomControl, UseMapTypeControl = model.UseMapTypeControl, UseStreetViewControl = model.UseStreetViewControl, ScrollWheelEnabled = model.ScrollWheelEnabled, UseHybridMap = model.UseHybridMap }; return(apiResult); } }