Beispiel #1
0
        private string CreateItem(TemplateDefinition template, NameValueCollection request)
        {
            var path = new PathData(navigator.Navigate(request["below"]));

            if (!versionRepository.TryParseVersion(request[PathData.VersionIndexQueryKey], request[PathData.VersionKeyQueryKey], path))
            {
                path.CurrentItem = versions.AddVersion(path.CurrentItem, asPreviousVersion: false);
            }
            var parent = path.CurrentItem;

            ContentItem item = activator.CreateInstance(template.Definition.ItemType, parent);

            item.ZoneName    = request["zone"];
            item.TemplateKey = template.Name;

            string beforeVersionKey = request["beforeVersionKey"];
            string beforeSortOrder  = request["beforeSortOrder"];
            string before           = request["before"];

            if (string.IsNullOrEmpty(beforeSortOrder))
            {
                item.AddTo(parent);
            }
            else
            {
                int index = int.Parse(beforeSortOrder);
                parent.InsertChildBefore(item, index);
            }

            versionRepository.Save(parent);
            return(request["returnUrl"].ToUrl().SetQueryParameter(PathData.VersionIndexQueryKey, parent.VersionIndex));
        }