예제 #1
0
        // todo: should refactor to save all items in 1 transaction
        public Dictionary <Guid, int> SaveMany([FromUri] int appId, [FromBody] List <EntityWithHeader> items)
        {
            // before we create/save/update it, we must check if it's new, in case we must add it to a group
            // only add if the header wants it, AND we started with ID unknown
            // var allowAddGroup = items.First().Entity.Id == 0;

            // first, save all to do it in 1 transaction
            // note that it won't save the SlotIsEmpty ones, as these won't be needed
            var postSaveIds = _entitiesController.SaveMany(appId, items.Select(i => new EntityWithHeader {
                Header = i.Header, Entity = i.Entity
            }).ToList());

            // now assign all content-groups as needed
            var groupItems = items
                             .Where(i => i.Header.Group != null)
                             .GroupBy(i => i.Header.Group.Guid.ToString() + i.Header.Group.Index.ToString() + i.Header.Group.Add)
                             .ToList();

            if (groupItems.Any())
            {
                DoAdditionalGroupProcessing(appId, postSaveIds, groupItems);
            }

            return(postSaveIds);
        }
예제 #2
0
        private Dictionary <Guid, int> SaveOldFormatKeepTillReplaced(int appId,
                                                                     List <BundleWithHeader <EntityWithLanguages> > items,
                                                                     bool partOfPage,
                                                                     bool forceDraft)
        {
            Log.Add($"SaveAndProcessGroups(..., appId:{appId}, items:{items?.Count}), partOfPage:{partOfPage}, forceDraft:{forceDraft}");

            // first, save all to do it in 1 transaction
            // note that it won't save the SlotIsEmpty ones, as these won't be needed
            var eavEntitiesController = new Eav.WebApi.EntitiesController(Log);

            return(eavEntitiesController.SaveMany(appId, items, partOfPage, forceDraft));
        }
예제 #3
0
        // todo: should refactor to save all items in 1 transaction
        public Dictionary <Guid, int> SaveMany([FromUri] int appId, [FromBody] List <EntityWithHeader> items)
        {
            // first, save all to do it in 1 transaction
            // note that it won't save the SlotIsEmpty ones, as these won't be needed
            var postSaveIds = _entitiesController.SaveMany(appId, items.Select(i => new EntityWithHeader {
                Header = i.Header, Entity = i.Entity
            }).ToList());

            // now assign all content-groups as needed
            var groupItems = items
                             .Where(i => i.Header.Group != null)
                             .GroupBy(i => i.Header.Group.Guid.ToString() + i.Header.Group.Index.ToString() + i.Header.Group.Add)
                             .ToList();

            if (groupItems.Any())
            {
                DoAdditionalGroupProcessing(appId, postSaveIds, groupItems);
            }

            return(postSaveIds);
        }