private void ModifyItemList(int parentId, string field, IItemListAction actionToPerform) { var parentEntity = SxcContext.App.Data["Default"].List[parentId]; var parentField = parentEntity.GetBestValue(field); var fieldList = parentField as Eav.Data.EntityRelationship; if (fieldList == null) { throw new Exception("field " + field + " doesn't seem to be a list of content-items, must abort"); } var ids = fieldList.EntityIds.ToList(); if (!actionToPerform.Change(ids)) { return; } // save var values = new Dictionary <string, object> { { field, ids.ToArray() } }; var cgApp = SxcContext.App; var eavDc = EavDataController.Instance(cgApp.ZoneId, cgApp.AppId); eavDc.UserName = Environment.Dnn7.UserIdentity.CurrentUserIdentityToken; eavDc.Entities.UpdateEntity(parentEntity.EntityGuid, values); }
// todo: probably should move to the new Eav.Apps section, but for that we must private void ModifyItemList(int parentId, string field, IItemListAction actionToPerform) { Log.Add($"modify item list parent:{parentId}, field:{field}, action:{actionToPerform}"); var parentEntity = SxcContext.App.Data["Default"].List[parentId]; var parentField = parentEntity.GetBestValue(field); if (!(parentField is EntityRelationship fieldList)) { throw new Exception("field " + field + " doesn't seem to be a list of content-items, must abort"); } var ids = fieldList.EntityIds.ToList(); if (!actionToPerform.Change(ids)) { return; } // save var values = new Dictionary <string, object> { { field, ids.ToArray() } }; new AppManager(SxcContext.App, Log).Entities.UpdateParts(parentEntity.EntityId, values); }
private void ModifyItemList(int parentId, string field, IItemListAction actionToPerform) { var parentEntity = SxcContext.App.Data["Default"].List[parentId]; var parentField = parentEntity.GetBestValue(field); var fieldList = parentField as Eav.Data.EntityRelationship; if (fieldList == null) throw new Exception("field " + field + " doesn't seem to be a list of content-items, must abort"); var ids = fieldList.EntityIds.ToList(); if (!actionToPerform.Change(ids)) return; // save var values = new Dictionary<string, object> {{field, ids.ToArray()}}; var cgApp = SxcContext.App; var eavDc = EavDataController.Instance(cgApp.ZoneId, cgApp.AppId); eavDc.UserName = Environment.Dnn7.UserIdentity.CurrentUserIdentityToken; eavDc.Entities.UpdateEntity(parentEntity.EntityGuid, values); }