示例#1
0
        public ActionResult UpdateOverlays(string name, string points, string color, string xy, Guid id, bool isUpdatePoints)
        {
            MapOverlay mapOverlay = service.Get(id);

            if (mapOverlay == null)
            {
                throw new NopException("遮盖物不存在");
            }
            mapOverlay.Name  = name;
            mapOverlay.Color = color;
            if (!string.IsNullOrEmpty(xy))
            {
                mapOverlay.Longitude = xy.Split(',')[0];
                mapOverlay.Latitude  = xy.Split(',')[1];
            }
            service.Modify(mapOverlay);

            if (isUpdatePoints)
            {
                if (points != null)
                {
                    var coordinates   = points.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
                    var pointsEntitys = new List <MapOverlayPoints>();
                    foreach (var coordinate in coordinates)
                    {
                        var tmp   = coordinate.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                        var point = new MapOverlayPoints()
                        {
                            Longitude = tmp[0], Latitude = tmp[1], MapOverlayId = mapOverlay.Id
                        };
                        pointsEntitys.Add(point);
                    }
                    service.DeleteMapOverlayPoints(id);
                    service.BatchAdd(pointsEntitys);
                }
            }


            return(Content("1"));
        }