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); } }
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); }
public void DeleteCategory(int categoryId) { _categoryGateway.Delete(categoryId); _searchService.RemoveFromIndex(typeof(Category), categoryId); //RemoveObjectFromCache("Categories"); }
public bool Delete(int categoryID) { return(categoryGateway.Delete(categoryID) > 0); }