Example #1
0
        private void CopyItem(Item sourceItem, Item destination, ID newState)
        {
            var resultItem = BucketManager.IsItemContainedWithinBucket(sourceItem)
                ? BucketManager.CopyItem(destination, sourceItem, true)
                : sourceItem.CopyTo(destination, sourceItem.Name);

            //Update info sourceItem
            sourceItem.Editing.BeginEdit();
            ((NameValueListField)sourceItem.Fields[HiddenFields.Templates.HiddenField.Fields.TargetIds]).NameValues
                = new NameValueCollection {
                { resultItem.GetSiteItem().ID.ToShortID().ToString(), resultItem.ID.Guid.ToString().ToUpper() }
                };
            ((CheckboxField)sourceItem.Fields[Multisite.Templates.MainSite.Fields.IsDisplayOnMainSite]).Checked = true;
            sourceItem.Editing.EndEdit();
            //Update info copiedItem
            resultItem.Editing.BeginEdit();
            resultItem.Fields[HiddenFields.Templates.HiddenField.Fields.SourceId].SetValue(sourceItem.ID.ToString(), true);
            ((MultilistField)resultItem.Fields[Templates.MallSite.Fields.SiteDisplaySettings]).Add(sourceItem.GetSiteItem().ID.ToString());
            resultItem.Fields[FieldIDs.State].Value = newState.ToString();
            resultItem.Editing.EndEdit();
        }