Пример #1
0
        public async Task RemoveAsync(Expression <Func <Discount, bool> > expression)
        {
            var discountsToRemove = _discountRepository.Get().Where(expression).ToList();

            discountsToRemove.ForEach(d =>
            {
                _searchService.RemoveAsync(d.Id);

                _historyService.CreateAsync(UserAction.Remove,
                                            "Removed discount " + d.Conditions);

                _statisticsService.RemoveAsync(d.Id);

                _notificationService.RemoveDiscountNotificationsAsync(d.Id);
            });

            await _discountRepository.RemoveAsync(expression);

            var discountsToRemoveIds = discountsToRemove.Select(d => d.Id);
            await _favoritesService.RemoveManyAsync(discountsToRemoveIds);
        }