Пример #1
0
        public virtual async Task DeleteAsync(string[] ids, string[] memberTypes = null)
        {
            using (var repository = _repositoryFactory())
            {
                var members = await GetByIdsAsync(ids, null, memberTypes);

                if (!members.IsNullOrEmpty())
                {
                    var changedEntries = members.Select(x => new GenericChangedEntry <Member>(x, EntryState.Deleted)).ToArray();
                    await _eventPublisher.Publish(new MemberChangingEvent(changedEntries));

                    await repository.RemoveMembersByIdsAsync(members.Select(m => m.Id).ToArray());

                    await repository.UnitOfWork.CommitAsync();

                    foreach (var member in members)
                    {
                        await _dynamicPropertyService.DeleteDynamicPropertyValuesAsync(member);
                    }
                    await _eventPublisher.Publish(new MemberChangedEvent(changedEntries));
                }

                ClearCache(members);
            }
        }
Пример #2
0
        public async Task Handle(MemberChangedEvent message)
        {
            foreach (var changedEntry in message.ChangedEntries)
            {
                if (changedEntry.EntryState == EntryState.Added)
                {
                    await _dynamicPropertyService.SaveDynamicPropertyValuesAsync(changedEntry.NewEntry);

                    if (changedEntry.NewEntry is ISeoSupport seoSupport)
                    {
                        await _seoService.SaveSeoForObjectsAsync(new[] { seoSupport });
                    }
                }
                else if (changedEntry.EntryState == EntryState.Modified)
                {
                    await _dynamicPropertyService.SaveDynamicPropertyValuesAsync(changedEntry.NewEntry);

                    if (changedEntry.NewEntry is ISeoSupport seoSupport)
                    {
                        await _seoService.SaveSeoForObjectsAsync(new[] { seoSupport });
                    }
                }
                else if (changedEntry.EntryState == EntryState.Deleted)
                {
                    await _dynamicPropertyService.DeleteDynamicPropertyValuesAsync(changedEntry.NewEntry);

                    if (changedEntry.NewEntry is ISeoSupport seoSupport)
                    {
                        await _seoService.DeleteSeoForObjectAsync(seoSupport);
                    }
                }
            }
        }
Пример #3
0
 public virtual async Task Handle(StoreChangedEvent message)
 {
     foreach (var changedEntry in message.ChangedEntries)
     {
         if (changedEntry.EntryState == EntryState.Added)
         {
             var taskUpsertSeoForObjects       = _seoService.SaveSeoForObjectsAsync(new[] { changedEntry.NewEntry });
             var taskSaveDynamicPropertyValues = _dynamicPropertyService.SaveDynamicPropertyValuesAsync(changedEntry.NewEntry);
             var taskSaveEntitySettingsValues  = _settingManager.DeepSaveSettingsAsync(changedEntry.NewEntry);
             await Task.WhenAll(taskUpsertSeoForObjects, taskSaveDynamicPropertyValues, taskSaveEntitySettingsValues);
         }
         else if (changedEntry.EntryState == EntryState.Modified)
         {
             var taskUpsertSeoForObjects       = _seoService.SaveSeoForObjectsAsync(new[] { changedEntry.NewEntry });
             var taskSaveDynamicPropertyValues = _dynamicPropertyService.SaveDynamicPropertyValuesAsync(changedEntry.NewEntry);
             var taskSaveEntitySettingsValues  = _settingManager.DeepSaveSettingsAsync(changedEntry.NewEntry);
             await Task.WhenAll(taskUpsertSeoForObjects, taskSaveDynamicPropertyValues, taskSaveEntitySettingsValues);
         }
         else if (changedEntry.EntryState == EntryState.Deleted)
         {
             var taskDeleteSeoForObject          = _seoService.DeleteSeoForObjectAsync(changedEntry.NewEntry);
             var taskDeleteDynamicPropertyValues = _dynamicPropertyService.DeleteDynamicPropertyValuesAsync(changedEntry.NewEntry);
             var taskRemoveEntitySettingsValues  = _settingManager.DeepRemoveSettingsAsync(changedEntry.NewEntry);
             await Task.WhenAll(taskDeleteSeoForObject, taskDeleteDynamicPropertyValues, taskRemoveEntitySettingsValues);
         }
     }
 }
Пример #4
0
 public virtual async Task Handle(CartChangedEvent message)
 {
     foreach (var changedEntry in message.ChangedEntries)
     {
         if (changedEntry.EntryState == EntryState.Added)
         {
             await _dynamicPropertyService.SaveDynamicPropertyValuesAsync(changedEntry.NewEntry);
         }
         else if (changedEntry.EntryState == EntryState.Modified)
         {
             await _dynamicPropertyService.SaveDynamicPropertyValuesAsync(changedEntry.NewEntry);
             await TryDeleteDynamicPropertiesForRemovedLineItems(changedEntry);
         }
         else if (changedEntry.EntryState == EntryState.Deleted)
         {
             await _dynamicPropertyService.DeleteDynamicPropertyValuesAsync(changedEntry.NewEntry);
         }
     }
 }
Пример #5
0
        public async Task Handle(DynamicContentItemChangedEvent message)
        {
            foreach (var changedEntry in message.ChangedEntries)
            {
                switch (changedEntry.EntryState)
                {
                case EntryState.Added:
                case EntryState.Modified:
                    await _dynamicPropertyService.SaveDynamicPropertyValuesAsync(changedEntry.NewEntry);

                    break;

                case EntryState.Deleted:
                    await _dynamicPropertyService.DeleteDynamicPropertyValuesAsync(changedEntry.NewEntry);

                    break;
                }
            }
        }
Пример #6
0
        public virtual async Task DeleteAsync(string[] ids)
        {
            var orders = await GetByIdsAsync(ids, CustomerOrderResponseGroup.Full.ToString());

            using (var repository = _repositoryFactory())
            {
                //Raise domain events before deletion
                var changedEntries = orders.Select(x => new GenericChangedEntry <CustomerOrder>(x, EntryState.Deleted));
                await _eventPublisher.Publish(new OrderChangeEvent(changedEntries));

                await repository.RemoveOrdersByIdsAsync(ids);

                foreach (var order in orders)
                {
                    await _dynamicPropertyService.DeleteDynamicPropertyValuesAsync(order);
                }

                await repository.UnitOfWork.CommitAsync();

                //Raise domain events after deletion
                await _eventPublisher.Publish(new OrderChangedEvent(changedEntries));
            }
            ClearCache(orders);
        }
 protected virtual async Task DeleteDynamicPropertyValuesAsync(Store entry)
 {
     var taskDeleteDynamicPropertyValues = _dynamicPropertyService.DeleteDynamicPropertyValuesAsync(entry);
     var taskRemoveEntitySettingsValues  = _settingManager.DeepRemoveSettingsAsync(entry);
     await Task.WhenAll(taskDeleteDynamicPropertyValues, taskRemoveEntitySettingsValues);
 }
        public void DeleteDynamicPropertyValuesInBackground(DynamicContentItem newEntry)
        {
            var dynamicProperties = (IHasDynamicProperties)newEntry;

            _dynamicPropertyService.DeleteDynamicPropertyValuesAsync(dynamicProperties).GetAwaiter().GetResult();
        }