/// <summary> /// Deletes a news catalogues mapping /// </summary> /// <param name="newsCatalogues">News catalogues</param> public virtual void DeleteNewsCatalogues(NewsCatalogues newsCatalogues) { if (newsCatalogues == null) { throw new ArgumentNullException("newsCatalogues"); } _newsCataloguesRepository.Delete(newsCatalogues); //cache _cacheManager.RemoveByPattern(CATALOGUES_PATTERN_KEY); _cacheManager.RemoveByPattern(NEWSCATALOGUES_PATTERN_KEY); //event notification _eventPublisher.EntityDeleted(newsCatalogues); }
/// <summary> /// Delete a product tag /// </summary> /// <param name="productTag">Product tag</param> public virtual void DeleteProductTag(ProductTag productTag) { if (productTag == null) { throw new ArgumentNullException(nameof(productTag)); } _productTagRepository.Delete(productTag); //cache _cacheManager.RemoveByPrefix(QNetCatalogDefaults.ProductTagPrefixCacheKey); _staticCacheManager.RemoveByPrefix(QNetCatalogDefaults.ProductTagPrefixCacheKey); //event notification _eventPublisher.EntityDeleted(productTag); }
/// <summary> /// Delete a product tag /// </summary> /// <param name="productTag">Product tag</param> public virtual void DeleteProductTag(ProductTag productTag) { if (productTag == null) { throw new ArgumentNullException(nameof(productTag)); } _productTagRepository.Delete(productTag); //cache _cacheManager.RemoveByPattern(PRODUCTTAG_PATTERN_KEY); _staticCacheManager.RemoveByPattern(PRODUCTTAG_PATTERN_KEY); //event notification _eventPublisher.EntityDeleted(productTag); }
/// <summary> /// Deletes a file /// </summary> /// <param name="file">File</param> public virtual void DeleteFile(File file) { if (file == null) { throw new ArgumentNullException("file"); } //delete from file system DeleteFileOnFileSystem(file); //delete from database _fileRepository.Delete(file); //event notification _eventPublisher.EntityDeleted(file); }
/// <summary> /// Delete a customer tag /// </summary> /// <param name="customerTag">Customer tag</param> public virtual void DeleteCustomerTag(CustomerTag customerTag) { if (customerTag == null) { throw new ArgumentNullException("productTag"); } var builder = Builders <Customer> .Update; var updatefilter = builder.Pull(x => x.CustomerTags, customerTag.Id); var result = _customerRepository.Collection.UpdateManyAsync(new BsonDocument(), updatefilter).Result; _customerTagRepository.Delete(customerTag); //event notification _eventPublisher.EntityDeleted(customerTag); }
public virtual void DeletePicture(Picture picture) { Guard.NotNull(picture, nameof(picture)); // delete thumbs _imageCache.DeleteCachedImages(picture); // delete from storage _storageProvider.Value.Remove(picture.ToMedia()); // delete entity _pictureRepository.Delete(picture); // event notification _eventPublisher.EntityDeleted(picture); }
/// <summary> /// Deletes a product manufacturer mapping /// </summary> /// <param name="productManufacturer">Product manufacturer mapping</param> public virtual void DeleteProductManufacturer(ProductManufacturer productManufacturer) { if (productManufacturer == null) { throw new ArgumentNullException("productManufacturer"); } _productManufacturerRepository.Delete(productManufacturer); //cache _cacheManager.RemoveByPattern(MANUFACTURERS_PATTERN_KEY); _cacheManager.RemoveByPattern(PRODUCTMANUFACTURERS_PATTERN_KEY); //event notification _eventPublisher.EntityDeleted(productManufacturer); }
/// <summary> /// Deletes a product category mapping /// </summary> /// <param name="productCategory">Product category</param> public virtual void DeleteProductCategory(ProductCategory productCategory) { if (productCategory == null) { throw new ArgumentNullException("productCategory"); } _productCategoryRepository.Delete(productCategory); //cache _cacheManager.RemoveByPattern(CATEGORIES_PATTERN_KEY); _cacheManager.RemoveByPattern(PRODUCTCATEGORIES_PATTERN_KEY); //event notification _eventPublisher.EntityDeleted(productCategory); }
public virtual async Task DeleteAsync(int id) { var record = await FindByIdAsync(id); await _dbContext.NavBarItems.Where(p => p.Id == id).DeleteAsync(); await _localizedEntityService.DeleteEntityAllLocalizedStringsAsync(record); await _dbContext.NavBarItems.Where(p => p.Index > record.Index).UpdateAsync(p => new TblNavBarItems() { Index = p.Index - 1 }); QueryCacheManager.ExpireTag(CacheTags.NavbarItem); _eventPublisher.EntityDeleted(record); }
public virtual async Task DeleteAsync(int id) { var record = await FindByIdAsync(id); if (record != null && record.IsMainCurrency) { throw new Exception($"You can not delete system default currency (Id: {id})."); } await _dbContext.Currencies.Where(p => p.Id == id).DeleteAsync(); await _localizedEntityService.DeleteEntityAllLocalizedStringsAsync(record); QueryCacheManager.ExpireTag(CacheTags.Currency); _eventPublisher.EntityDeleted(record); }
public virtual void DeleteQuantityUnit(QuantityUnit quantityUnit) { if (quantityUnit == null) { throw new ArgumentNullException("quantityUnit"); } if (this.IsAssociated(quantityUnit.Id)) { throw new SmartException("The quantity unit cannot be deleted. It has associated product variants"); } _quantityUnitRepository.Delete(quantityUnit); //event notification _eventPublisher.EntityDeleted(quantityUnit); }
public virtual void DeleteDeliveryTime(DeliveryTime deliveryTime) { if (deliveryTime == null) { throw new ArgumentNullException("deliveryTime"); } if (this.IsAssociated(deliveryTime.Id)) { throw new SmartException(T("Admin.Configuration.DeliveryTimes.CannotDeleteAssignedProducts")); } _deliveryTimeRepository.Delete(deliveryTime); //event notification _eventPublisher.EntityDeleted(deliveryTime); }
/// <summary> /// Deletes a store /// </summary> /// <param name="store">Store</param> public virtual void DeleteStore(Store store) { if (store == null) throw new ArgumentNullException("store"); var allStores = GetAllStores(); if (allStores.Count == 1) throw new Exception("You cannot delete the only configured store"); _storeRepository.Delete(store); //clear cache _cacheManager.Clear(); //event notification _eventPublisher.EntityDeleted(store); }
public ServiceOperationResult DeletePicture(Picture picture, bool onlyChangeFlag = false) { var result = EngineContext.Current.Resolve <ServiceOperationResult>(); if (picture == null) { result.AddResourceError(CommonConstants.Systematic.NullEntity); return(result); } if (GetPictureById(picture.Id) == null) { result.AddResourceError(CommonConstants.Systematic.UnknownEntity); return(result); } if (onlyChangeFlag) { picture.IsDeleted = true; _pictureRepository.Update(picture); } else { try { _pictureRepository.Insert(picture); } catch (InvalidStateException invalidStateException) { result.InjectExceptionMessages(invalidStateException); result.Exception = invalidStateException; return(result); } catch (Exception exception) { result.Exception = exception; return(result); } } DeletePictureThumbs(picture); if (!StoreInDb) { DeletePictureOnFileSystem(picture); } _eventPublisher.EntityDeleted(picture); return(result); }
/// <summary> /// Deletes an email account /// </summary> /// <param name="emailAccount">Email account</param> public virtual void DeleteEmailAccount(EmailAccount emailAccount) { if (emailAccount == null) { throw new ArgumentNullException(nameof(emailAccount)); } if (GetAllEmailAccounts().Count == 1) { throw new NopException("You cannot delete this email account. At least one account is required."); } _emailAccountRepository.Delete(emailAccount); //event notification _eventPublisher.EntityDeleted(emailAccount); }
/// <summary> /// Deletes DeliveryTime /// </summary> /// <param name="currency">DeliveryTime</param> public virtual void DeleteDeliveryTime(DeliveryTime deliveryTime) { if (deliveryTime == null) { throw new ArgumentNullException("deliveryTime"); } //if (this.IsAssociated(deliveryTime.Id)) // throw new WorkException("The delivery time cannot be deleted. It has associated product variants"); _deliveryTimeRepository.Delete(deliveryTime); _cacheManager.RemoveByPattern(DELIVERYTIMES_PATTERN_KEY); //event notification _eventPublisher.EntityDeleted(deliveryTime); }
/// <summary> /// 删除 /// </summary> /// <param name="request"></param> /// <returns></returns> public ServResult DeleteCategory(ServRequest <DeleteCategoryDto> request) { Category category = null; using (var client = DbFactory.GetClient()) { category = client.Queryable <Category>().InSingle(request.Data.Id); if (category == null) { return(Error("找不到该条信息")); } client.Deleteable <Category>(request.Data.Id).ExecuteCommand(); } _distributedCache.Remove(CACHE_CATEGORY_ALL_KEY); _eventPublisher.EntityDeleted(category); return(Ok()); }
/// <summary> /// Deletes a language /// </summary> /// <param name="language">Language</param> public virtual void DeleteLanguage(Language language) { if (language == null) { throw new ArgumentNullException("language"); } _languageRepository.Delete(language); //cache _cacheManager.RemoveByPattern(LANGUAGES_PATTERN_KEY); //event notification _eventPublisher.EntityDeleted(language); }
/// <summary> /// Deletes a brand /// </summary> /// <param name="brand">Brand</param> public virtual void DeleteBrand(Brand brand) { if (brand == null) { throw new ArgumentNullException("brand"); } brand.Deleted = true; UpdateBrand(brand); //cache _cacheManager.RemoveByPattern(BRAND_PATTERN_KEY); //event notification _eventPublisher.EntityDeleted(brand); }
public virtual void DeleteProductAttribute(ProductAttribute productAttribute) { if (productAttribute == null) { throw new ArgumentNullException("productAttribute"); } _productAttributeRepository.Delete(productAttribute); //cache _requestCache.RemoveByPattern(PRODUCTVARIANTATTRIBUTES_PATTERN_KEY); _requestCache.RemoveByPattern(PRODUCTVARIANTATTRIBUTEVALUES_PATTERN_KEY); //event notification _eventPublisher.EntityDeleted(productAttribute); }
public virtual void DeleteEmailAccount(EmailAccount emailAccount) { if (emailAccount == null) { throw new ArgumentNullException("emailAccount"); } if (GetAllEmailAccounts().Count == 1) { throw new SmartException("You cannot delete this email account. At least one account is required."); } _emailAccountRepository.Delete(emailAccount); _defaultEmailAccount = null; _eventPublisher.EntityDeleted(emailAccount); }
public virtual void DeleteBid(Bid bid) { if (bid == null) { throw new ArgumentNullException("bid"); } _bidRepository.Delete(bid); _eventPublisher.EntityDeleted(bid); var productToUpdate = _productService.GetProductById(bid.ProductId); var highestBid = GetBidsByProductId(bid.ProductId).OrderByDescending(x => x.Amount).FirstOrDefault(); if (productToUpdate != null) { UpdateHighestBid(productToUpdate, highestBid != null ? highestBid.Amount: 0, highestBid != null ? highestBid.CustomerId : ""); } }
/// <summary> /// Deletes an email account /// </summary> /// <param name="emailAccount">Email account</param> public virtual async Task DeleteEmailAccount(EmailAccount emailAccount) { if (emailAccount == null) { throw new ArgumentNullException("emailAccount"); } var emailAccounts = await GetAllEmailAccounts(); if (emailAccounts.Count == 1) { throw new GrandException("You cannot delete this email account. At least one account is required."); } await _emailAccountRepository.DeleteAsync(emailAccount); //event notification await _eventPublisher.EntityDeleted(emailAccount); }
public void DeleteCustomerRole(CustomerRole customerRole) { if (customerRole == null) { throw new ArgumentNullException("customerRole"); } if (customerRole.IsSystemRole) { throw new NopException("System role could not be deleted"); } _customerRoleRepository.Delete(customerRole); _cacheManager.RemoveByPattern(CUSTOMERROLES_PATTERN_KEY); _eventPublisher.EntityDeleted(customerRole); }
/// <summary> /// Delete a user /// </summary> public async Task DeleteUserAsync(User user) { if (user == null) { throw new ArgumentNullException(nameof(user)); } if (user.IsSystemAccount) { throw new DefaultException($"System user account ({user.SystemName}) could not be deleted"); } user.Deleted = true; await UpdateUserAsync(user); _eventPublisher.EntityDeleted(user); }
public virtual void DeleteCompany(Company company) { if (company == null) { throw new ArgumentNullException(nameof(company)); } if (company is IEntityForCaching) { throw new ArgumentException("Cacheable entities are not supported by Entity Framework"); } company.Deleted = true; UpdateCompany(company); //event notification _eventPublisher.EntityDeleted(company); }
/// <summary> /// Deletes the product by identifier. /// </summary> /// <param name="productId">The product identifier.</param> public void DeleteProductById(int productId) { var product = _productService.GetProductById(productId); if (product == null) { return; } _productService.DeleteProduct(product); //update _productRepository.Delete(product); //cache _cacheManager.RemoveByPattern(ProductsPatternKey); //event notification _eventPublisher.EntityDeleted(product); }
/// <summary> /// Deletes currency /// </summary> /// <param name="currency">Currency</param> public virtual void DeleteCurrency(Currency currency) { if (currency == null) { throw new ArgumentNullException(nameof(currency)); } if (currency is IEntityForCaching) { throw new ArgumentException("Cacheable entities are not supported by Entity Framework"); } _currencyRepository.Delete(currency); _cacheManager.RemoveByPrefix(NopDirectoryDefaults.CurrenciesPrefixCacheKey); //event notification _eventPublisher.EntityDeleted(currency); }
/// <summary> /// Deletes a store /// </summary> /// <param name="store">Store</param> public virtual void DeleteStore(Store store) { if (store == null) { throw new ArgumentNullException(nameof(store)); } var allStores = GetAllStores(); if (allStores.Count == 1) { throw new Exception("You cannot delete the only configured store"); } _storeRepository.Delete(store); //event notification _eventPublisher.EntityDeleted(store); }
/// <summary> /// Deletes currency /// </summary> /// <param name="currency">Currency</param> public virtual void DeleteCurrency(Currency currency) { if (currency == null) { throw new ArgumentNullException(nameof(currency)); } if (currency is IEntityForCaching) { throw new ArgumentException("Cacheable entities are not supported by Entity Framework"); } _currencyRepository.Delete(currency); _cacheManager.RemoveByPattern(CURRENCIES_PATTERN_KEY); //event notification _eventPublisher.EntityDeleted(currency); }