ToSic.SexyContent.ContentGroup.AddContentAndPresentationEntity C# (CSharp) Method

AddContentAndPresentationEntity() public method

If SortOrder is not specified, adds at the end
public AddContentAndPresentationEntity ( string type, int sortOrder, int contentId, int presentationId ) : void
type string
sortOrder int
contentId int
presentationId int
return void
        public void AddContentAndPresentationEntity(string type, int? sortOrder, int? contentId, int? presentationId)
        {
            if (type.ToLower() != cContent.ToLower())
                throw new Exception("This is only meant to work for content, not for list-content");

            if (!sortOrder.HasValue)
                sortOrder = Content.Count;

            var list1 = ListWithNulls(type);
            list1.Insert(sortOrder.Value, contentId);

            var list2 = GetPresentationIdWithSameLengthAsContent();
            list2.Insert(sortOrder.Value, presentationId);

            SaveChangedLists(PrepareSavePackage(cContent, list1, PrepareSavePackage(cPresentation, list2)));
        }