Exemplo n.º 1
0
 /// <summary>
 /// Swap the reference to oldItem for a reference to newItem
 /// </summary>
 /// <param name="oldItem"></param>
 /// <param name="newItem"></param>
 public void Switch(Item oldItem, Item newItem)
 {
     using (new SecurityDisabler()) {
         if (_isLinkField)
         {
             _field.SetLinkField(newItem, (_field.TypeKey == "internal link"));
         }
         else
         {
             MultilistField mf = _field;
             if (!_field.Item.Editing.IsEditing)
             {
                 using (new EditContext(_field.Item)) {
                     mf.Replace(oldItem.ID.ToString(), newItem.ID.ToString());
                 }
             }
             else
             {
                 mf.Replace(oldItem.ID.ToString(), newItem.ID.ToString());
             }
         }
     }
 }