public ActionResult DeleteConfirmed(int id) { productcategoryRepository.Delete(id); productcategoryRepository.Save(); return(RedirectToAction("Index")); }
public async Task <MediatR.Unit> Handle(DeleteProductCategoryCommand request, CancellationToken cancellationToken) { // get productCategory by id var productCategoryFromRepo = await _productCategoryRepository.FindByIdAsync(request.ProductCategoryId); if (productCategoryFromRepo == null) { throw new ProductCategoryNotFoundException(request.ProductCategoryId); } if (productCategoryFromRepo.Products.Count > 0) { throw new ProductCategoryContainsProductsException(request.ProductCategoryId); } // we call delete productCategory to rase delete productCategory event to sync with algolia productCategoryFromRepo.Delete(); // update productCategory with the new unit deleted _productCategoryRepository.Delete(productCategoryFromRepo); // save changes in the database and rase ProductCategoryUpdated event await _productCategoryRepository.UnitOfWork.SaveEntitiesAsync(cancellationToken); return(MediatR.Unit.Value); }
public void DeleteProductCategory(DeleteProductCategoryInput input) { var productcategory = _ProductCategoryRepository.Get(input.Id); productcategory.IsDeleted = true; _ProductCategoryRepository.Delete(productcategory); }
public async Task Delete(Guid id) { await ValidateEntityExistence(id); if (_notificationService.HasNotifications()) { return; } await _productCategoryRepository.Delete(id); }
public async Task <ActionResultResponse> Delete(string tenantId, int productCategoryId) { var productCategoryInfo = await _productCategoryRepository.GetInfo(productCategoryId); if (productCategoryInfo == null) { return(new ActionResultResponse(-1, _productResourceService.GetString("Product category does not exists. Please try again."))); } if (productCategoryInfo.TenantId != tenantId) { return(new ActionResultResponse(-2, _sharedResourceService.GetString(ErrorMessage.NotHavePermission))); } // Check is has child. var productCategoryChildCount = await _productCategoryRepository.GetChildCount(productCategoryInfo.Id); if (productCategoryChildCount > 0) { return(new ActionResultResponse(-3, _productResourceService.GetString("This Product category has children product category. You can not delete this Product category."))); } // Check is has product. var isExistsProduct = await _productsCategorieRepository.CheckCategoryHasProduct(productCategoryId); if (isExistsProduct) { return(new ActionResultResponse(-4, _productResourceService.GetString("This Product category has product. You can not delete this Product category."))); } //Check in ProductsCategories -- if exists return message var result = await _productCategoryRepository.Delete(productCategoryInfo.Id); if (result > 0 && productCategoryInfo.ParentId.HasValue) { //Update parent product category child count. var childCount = await _productCategoryRepository.GetChildCount(productCategoryInfo.ParentId.Value); await _productCategoryRepository.UpdateChildCount(productCategoryInfo.ParentId.Value, childCount); } var childTrans = await _productCategoryTranslationRepository.GetAllByProductCategoryId(productCategoryInfo.Id); foreach (ProductCategoryTranslation childTran in childTrans) { childTran.IsDelete = productCategoryInfo.IsDelete; await _productCategoryTranslationRepository.Update(childTran); } return(new ActionResultResponse(result, result > 0 ? _productResourceService.GetString("Delete product category successful.") : _sharedResourceService.GetString(ErrorMessage.SomethingWentWrong))); }
public ActionResult Delete(int prodcatId) { ProductCategory DeleteProductCategory = repository.Delete(prodcatId); if (DeleteProductCategory != null) { TempData["message"] = string.Format("{0} was deleted", DeleteProductCategory.Name); } return(RedirectToAction("Index")); }
public void DeleteProductCategories(int productCategoryId) { //Get productCategory by id. var productCategory = productCategoryRepository.GetById(productCategoryId); if (productCategory != null) { productCategoryRepository.Delete(productCategory); SaveProductCategory(); } }
public IActionResult Delete(int id) { if (id == 0) { return(new BadRequestResult()); } else { _productCategoryRepository.Delete(id); _productCategoryRepository.Save(); return(new OkObjectResult(id)); } }
/// <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.GetCache(CACHE_NAME_CATEGORIES).Clear(); _cacheManager.GetCache(CACHE_NAME_PRODUCTCATEGORIES).Clear(); //event notification //_eventPublisher.EntityDeleted(productCategory); }
public IActionResult DeleteProductCategory(int id) { var productCategory = productCategoryRepository.GetById(id); if (productCategory == null) { ViewBag.Title = "Usuń kategorię produktów"; ViewBag.ErrorMessage = "Nie znaleziono kategorii o danym identyfikatorze"; return(View("Error")); } productCategoryRepository.Delete(productCategory.Id); productCategoryRepository.Save(); return(RedirectToAction("ListProductCategories")); }
/// <summary> /// /// </summary> /// <param name="context"></param> /// <returns></returns> public async Task Consume(ConsumeContext <IDeleteProductCategory> context) { Log.Logger = new LoggerConfiguration() .MinimumLevel.Debug() .WriteTo.Console(theme: ConsoleTheme.None) .CreateLogger(); var start = Stopwatch.GetTimestamp(); Log.Information("Received command {CommandName}-{MessageId}: {@Messages}", GetType().Name, context.MessageId, context.Message); var productCategories = await _productCategoryRepository.Delete(context.Message); await context.RespondAsync <IProductCategoryDeleted>(new { Ids = productCategories.Select(s => s.Id) }); //index to es if (productCategories.Count > 0) { await _esClient.IndexManyAsync(productCategories, "product_categories"); } Log.Information("Completed command {CommandName}-{MessageId} {ExecuteTime}ms", GetType().Name, context.MessageId, (Stopwatch.GetTimestamp() - start) * 1000 / (double)Stopwatch.Frequency); }
public async Task Handle(JObject jObject, ILog log, CancellationToken cancellationToken) { try { log.Info("Consume DeletedEvent"); var dataConsomed = jObject.ToObject <ProductCategoryDeletedEvent>(); var data = await _productCategoryQueries.GetData(dataConsomed.ProductCategoryId); log.Info("Delete Customer"); //Consume data to Read Db _productCategoryRepository.Delete(data); await _uow.CommitAsync(); } catch (Exception ex) { log.Error("Error Deleteing data customer", ex); throw ex; } }
public Message Delete(int productCategoryId) { var message = new Message(); try { int result = _iProductCategoryRepository.Delete(productCategoryId); if (result > 0) { message = Message.SetMessages.SetSuccessMessage("ProductCategory Deleted Successfully."); } else { message = Message.SetMessages.SetErrorMessage("Failed to Delete Data."); } } catch (Exception ex) { message = Message.SetMessages.SetErrorMessage(ex.Message); } return(message); }
/// <summary> /// this method delets product from the category /// </summary> /// <param name="productId">product id</param> /// <param name="categoryId">category id</param> /// <param name="currentUserId">category id</param> public async Task <string> DeleteProductFromCategoryByIdAsync(int productId, int categoryId, string currentUserId) { var product = await _productRepository.GetByIdAsync(productId); var ProductCategory = _productCategoryRepository.FindAll().FirstOrDefault(x => x.ProductId == productId && x.CategoryId == categoryId); if (product == null) { throw new AuctionException("Product not found", System.Net.HttpStatusCode.NotFound); } else if (ProductCategory == null) { throw new AuctionException("Category not found", System.Net.HttpStatusCode.NotFound); } if (currentUserId == product.UserId) { _productCategoryRepository.Delete(ProductCategory); await _productCategoryRepository.SaveAsync(); return($"Product has been removed from category, Category Id :{categoryId}, ProductId : {productId}"); } throw new AuctionException("Product doesn't belong to user", System.Net.HttpStatusCode.Forbidden); }
public ProductCategory Delete(Guid id) { return(_productCategoryRepository.Delete(id)); }
public async Task Delete(int id) { await _productCategoryRepository.Delete(id); }
ProductCategory ICategoryService.Delete(int id) { return(_cateRepository.Delete(id)); //throw new NotImplementedException(); }
public bool Delete(ProductCategory entity) { return(repository.Delete(entity)); }
public void Delete(ProductCategory entity) { _ProductCategoryRepository.Delete(entity); }
public void DeleteProductCategory(long id) { productCategoryRepository.Delete(pc => pc.Id == id); }
public void Delete(int id) { _productCategoryRepository.Delete(id); }
public ProductCategory Delete(int id) { _ProductCategoryRepository.Delete(id); return(GetById(id)); }
public bool Delete(Guid id, Guid apiUserId) { return(_productCategoryRepository.Delete(id, apiUserId)); }
public ProductCategory Delete(ProductCategory productCategory) { var result = _productCategoryRepository.Delete(productCategory); return(_uow.Commit() ? result : null); }
public ProductCategory Delete(ProductCategory ProductCategory) { return(_ProductCategoryRepository.Delete(ProductCategory)); }
public void Delete(int id) { _proCatRepo.Delete(id); }
public void RemoveProductCategory(int Id) { var ProductCategory = ProductCategorysRepository.GetById(Id); ProductCategorysRepository.Delete(ProductCategory); }
public ProductCategory Delete(int id) { return(_productCategory.Delete(id)); }
public ProductCategory Delete(int id) { return(_ProductCategoryRepository.Delete(id)); }
public void Delete(Guid id) { productCategoryRepository.Delete(id); }