コード例 #1
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);
            }
        }
コード例 #2
0
        internal string Delete(int categoryId)
        {
            string message = "";

            if (itemGateway.DoesCategoryHasDependency(categoryId))
            {
                message = "Can not be deleted as an item exist of that category";
            }
            else
            {
                int rowAffected = categoryGateway.Delete(categoryId);

                if (rowAffected > 0)
                {
                    message = "Company Deleted Successfully";
                }
                else
                {
                    message = "Company Could Not Be Deleted";
                }
            }

            return(message);
        }
コード例 #3
0
 public void DeleteCategory(int categoryId)
 {
     _categoryGateway.Delete(categoryId);
     _searchService.RemoveFromIndex(typeof(Category), categoryId);
     //RemoveObjectFromCache("Categories");
 }
コード例 #4
0
 public bool Delete(int categoryID)
 {
     return(categoryGateway.Delete(categoryID) > 0);
 }