@@ -610,11 +610,10 @@ public class BlockGridLayoutItem
610610// this represents an item in the block grid content or settings data collection
611611public class BlockGridElementData
612612{
613- public BlockGridElementData (Guid contentTypeKey , Udi udi , Dictionary < string , object > data )
613+ public BlockGridElementData (Guid contentTypeKey , Udi udi )
614614 {
615615 ContentTypeKey = contentTypeKey ;
616616 Udi = udi ;
617- Data = data ;
618617 }
619618
620619 [JsonPropertyName (" contentTypeKey" )]
@@ -624,7 +623,7 @@ public class BlockGridElementData
624623 public Udi Udi { get ; }
625624
626625 [JsonExtensionData ]
627- public Dictionary <string , object > Data { get ; }
626+ public Dictionary <string , object >? Data { get ; }
628627}
629628```
630629{% endcode %}
@@ -643,11 +642,12 @@ using Umbraco.Cms.Core;
643642using Umbraco .Cms .Core .Models ;
644643using Umbraco .Cms .Core .Serialization ;
645644using Umbraco .Cms .Core .Services ;
646- using Umbraco .Cms .Web .Common .Controllers ;
647645
648646namespace My .Site .Controllers ;
649647
650- public class BlockGridTestController : UmbracoApiController
648+ [ApiController ]
649+ [Route (" /umbraco/api/blockgridtest" )]
650+ public class BlockGridTestController : Controller
651651{
652652 private readonly IContentService _contentService ;
653653 private readonly IContentTypeService _contentTypeService ;
@@ -661,11 +661,11 @@ public class BlockGridTestController : UmbracoApiController
661661 }
662662
663663 // POST: /umbraco/api/blockgridtest/create
664- [HttpPost ]
664+ [HttpPost ( " create " ) ]
665665 public ActionResult Create ()
666666 {
667667 // get the item content to modify
668- IContent ? content = _contentService .GetById (1203 );
668+ IContent ? content = _contentService .GetById (Guid . Parse ( " efba7b97-91b6-4ddf-b2cc-eef89ff48c3b " ) );
669669 if (content == null )
670670 {
671671 return NotFound (" Could not find the content item to modify" );
@@ -700,17 +700,23 @@ public class BlockGridTestController : UmbracoApiController
700700 layoutItems .Add (new BlockGridLayoutItem (contentUdi , settingsUdi , data .ColumnSpan , data .RowSpan ));
701701
702702 // create new content data
703- spotContentData .Add (new BlockGridElementData (spotContentType .Key , contentUdi , new Dictionary < string , object >
703+ spotContentData .Add (new BlockGridElementData (spotContentType .Key , contentUdi )
704704 {
705- { " title" , data .Title },
706- { " text" , data .Text },
707- }));
705+ Data = new Dictionary <string , object >
706+ {
707+ { " title" , data .Title },
708+ { " text" , data .Text },
709+ }
710+ });
708711
709712 // create new settings data
710- spotSettingsData .Add (new BlockGridElementData (spotSettingsType .Key , settingsUdi , new Dictionary < string , object >
713+ spotSettingsData .Add (new BlockGridElementData (spotSettingsType .Key , settingsUdi )
711714 {
712- { " featured" , data .Featured ? " 1" : " 0" },
713- }));
715+ Data = new Dictionary <string , object >
716+ {
717+ { " featured" , data .Featured ? " 1" : " 0" },
718+ }
719+ });
714720 }
715721
716722 // construct the block grid data from layout, content and settings
0 commit comments