private EditBingLocationViewModel BuildEditorViewModel(BingLocationPart part)
        {
            // Setting creation defaults - MapType is null on creation
            var mapType   = part.MapType ?? _mapListService.DefaultMapType;
            var isEnabled = (part.MapType != null) ? part.IsEnabled : true;

            var editModel = new EditBingLocationViewModel
            {
                LatitudeStr      = part.Latitude.toInvariantCultureString(),
                LongitudeStr     = part.Longitude.toInvariantCultureString(),
                Width            = part.Width,
                Height           = (part.Height == 0) ? 300 : part.Height,       // Default height
                Zoom             = part.Zoom,
                MapType          = mapType,
                BingMapLists     = _mapListService.GetBingMapLists(),
                MapTypeList      = _mapListService.CreateMapTypeList(mapType),
                PossibleMapIcons = GetPossibleMapIcons(),
                MapIcon          = part.MapIcon,
                MapIconFolder    = GetIconFolder(),
                IsEnabled        = isEnabled
            };

            if (part.BingMapList != null)
            {
                editModel.BingMapListId = part.BingMapList.Id;
            }

            return(editModel);
        }
Beispiel #2
0
 public void UpdateBingMapList(BingLocationPart part, EditBingLocationViewModel model)
 {
     if (model.BingMapListId != null)
     {
         part.BingMapList = _contentManager.Get((int)model.BingMapListId);
     }
     else
     {
         part.BingMapList = null;
     }
 }
        //POST
        protected override DriverResult Editor(BingLocationPart part, IUpdateModel updater, dynamic shapeHelper)
        {
            // Update main bits of location
            updater.TryUpdateModel(part, Prefix, null, null);

            // Update linked maplist bit of location
            var model = new EditBingLocationViewModel();

            updater.TryUpdateModel(model, Prefix, null, null);

            // Gets value from String version (means it also works in French)
            part.Latitude  = model.Latitude;
            part.Longitude = model.Longitude;

            if (part.ContentItem.Id != 0)
            {
                _mapListService.UpdateBingMapList(part, model);
            }

            return(Editor(part, shapeHelper));
        }