Ejemplo n.º 1
0
        public void DeleteAction(int actionId)
        {
            using (TransactionScope ts = new TransactionScope())
            {
                _actionGateway.Delete(actionId);
                _heartService.DeleteHeart(actionId);

                ts.Complete();
            }
        }
Ejemplo n.º 2
0
        public void DeleteManufacturer(int manufacturerId)
        {
            using (TransactionScope ts = new TransactionScope())
            {
                _manufacturerGateway.Delete(manufacturerId);
                _heartService.DeleteHeart(manufacturerId);

                ts.Complete();
            }
        }
Ejemplo n.º 3
0
 public void RemoveNewsItem(int id)
 {
     using (var ts = new TransactionScope())
     {
         //var heart = _heartService.GetHeart(id);
         _heartService.DeleteHeart(id);
         _tagGateway.DeleteUnassociated();
         _searchService.RemoveFromIndex(typeof(NewsItem), id);
         ts.Complete();
     }
 }
Ejemplo n.º 4
0
        public void DeletePage(int pageId)
        {
            using (var ts = new TransactionScope())
            {
                var heart = _heartService.GetHeart(pageId);
                _heartService.DeleteHeart(pageId);
                RemoveObjectFromCache(GetPageCacheKey(heart.RelativeUrl));
                _searchService.RemoveFromIndex(typeof(Page), pageId);

                ts.Complete();
            }
        }
Ejemplo n.º 5
0
        private void Delete(int heartId)
        {
            var shopService = DependencyResolver.Current.GetService <IShopService>();

            Data.Models.Category dataCategory = _categoryGateway.SelectOne(heartId);
            var goodsIds = _goodsCategoryGateway.SelectByCategory(heartId).Select(x => x.GoodsId);

            foreach (var goodsId in goodsIds)
            {
                var goodscats = _goodsCategoryGateway.SelectByGoods(goodsId);
                if (goodscats.Count() == 1)
                {
                    shopService.DeleteGoods(goodsId);
                }
            }

            var childCats = _categoryGateway.Select(heartId);

            foreach (var child in childCats)
            {
                Delete(child.HeartId);
            }

            _categoryGateway.Delete(heartId);
            var heart = _heartService.GetHeart(heartId);

            _heartService.DeleteHeart(heartId);


            RemoveObjectFromCache("Categories");
            RemoveObjectFromCache("AllCategories");
            RemoveObjectFromCache($"ChildCategoriesFor{dataCategory.ParentCategoryId}");

            RemoveObjectFromCache(GetCategoryCanonicalUrlCacheKey(heart.RelativeUrl));
            RemoveObjectFromCache(GetCategoryIDCanonicalUrlCacheKey(dataCategory.HeartId));

            int?lastCat = _settingsService.GetSettings <int?>("LastGoodsCategory");

            if (lastCat.HasValue && lastCat.Value == heartId)
            {
                _settingsService.Set <int?>("LastGoodsCategory", null);
            }
        }
Ejemplo n.º 6
0
        public void DeleteGoods(int heartId)
        {
            using (var ts = new TransactionScope())
            {
                //_goodsItemGateway.Delete(heartId);
                _heartService.DeleteHeart(heartId);

                foreach (var compatibleSetGoods in _compatibleSetGoodsGateway.SelectByGoods(heartId))
                {
                    _compatibleSetGoodsGateway.Delete(compatibleSetGoods);
                }
                foreach (var goodsCategory in _goodsCategoryGateway.SelectByGoods(heartId))
                {
                    _goodsCategoryGateway.Delete(goodsCategory);
                }
                foreach (var goodsImage in _goodsImageGateway.SelectByGoods(heartId))
                {
                    _goodsImageGateway.Delete(goodsImage);
                }
                foreach (var goodsReview in _goodsReviewGateway.SelectByGoods(heartId))
                {
                    _goodsReviewGateway.Delete(goodsReview.GoodsReviewId);
                }
                foreach (var actionGoods in _actionGoodsGateway.SelectByGoods(heartId))
                {
                    _actionGoodsGateway.Delete(actionGoods);
                }
                // упаковки не удаляем, так как они, возможно, понадобятся для истории заказов
                foreach (var goodsSpec in _goodsSpecGateway.SelectByGoods(heartId))
                {
                    _goodsSpecGateway.Delete(goodsSpec);
                }
                _searchService.RemoveFromIndex(typeof(GoodsItem), heartId);
                ts.Complete();
            }
        }