public void Create(ProductCategory entity) { if (string.IsNullOrEmpty(entity.Name)) { throw new BusinessException("Vui lòng nhập tên thể loại"); } if (string.IsNullOrEmpty(entity.Name)) { throw new BusinessException("Alias không được để trống"); } if (GetAll().Any(x => x.Name.ToUpper().Equals(entity.Name.ToUpper()))) { throw new BusinessException("Tên thể loại đã tồn tại. Vui lòng kiểm tra lại"); } if (string.IsNullOrEmpty(entity.Alias)) { entity.Alias = entity.Name.GetSeoTitle(); } productCategoryRepository.Create(entity); SaveChanges(); }
public void Create(CreateProductCategory command) { if (!_productCategoryRepository.Exists(command.Name)) { var productCategory = new ProductCategory(command.Name); _productCategoryRepository.Create(productCategory); _productCategoryRepository.SaveChanges(); } }
public OperationResult Create(CreateProductCategory command) { var operation = new OperationResult(); if (repo.Exist(c => c.Name == command.Name)) { return(operation.Failed("این نام تکراری است. لطفا نام دیگری انتخاب کنید")); } var slug = command.Slug.Slugify(); var productCatagory = new ProductCategory(command.Name, command.Description, command.Picture, command.PictureAlt, command.PictureTitle, command.Keywords, command.MetaDescription, slug); repo.Create(productCatagory); repo.SaveChange(); return(operation.Succedded()); }
public OperationResult Create(CreateProductCategory command) { var operation = new OperationResult(); if (_iProductCategoryRepository.Exists(x => x.Name == command.Name)) { return(operation.Failed(ApplicationMessages.DuplicatedRecord)); } var slug = command.Slug.Slugify(); var productcategory = new ProductCategory(command.Name, command.Description, command.Picture, command.PictureAlt, command.PictureTitle, command.Keywords, command.MetaDescription, slug); _iProductCategoryRepository.Create(productcategory); _iProductCategoryRepository.Save(); return(operation.Succeeded()); }
public OperationResult Create(CreateProductCategory command) { var operationResult = new OperationResult(); if (_productCategoryRepository.Exists(p => p.Name == command.Name)) { return(operationResult.Failed("امکان ثبت رکورد تکراری وجود ندارد.")); } var filename = _fileUploader.FileUpload(command.Picture, command.Slug); var produceCategory = new ProductCategory(command.Name, command.Description, filename, command.PictureAlt, command.PictureTitle, command.Keywords, command.MetaDescription, command.Slug.Slugify()); _productCategoryRepository.Create(produceCategory); _productCategoryRepository.SaveChanges(); return(operationResult.Succeeded()); }
/// <summary> /// /// </summary> /// <param name="context"></param> /// <returns></returns> public async Task Consume(ConsumeContext <ICreateProductCategory> 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 productCategory = await _productCategoryRepository.Create(context.Message); await context.RespondAsync(productCategory); await _esClient.IndexAsync(productCategory, idx => idx.Index("product_categories")); Log.Information("Completed command {CommandName}-{MessageId} {ExecuteTime}ms", GetType().Name, context.MessageId, (Stopwatch.GetTimestamp() - start) * 1000 / (double)Stopwatch.Frequency); }
public async Task Create(ProductCategoryRequestModel request) { await _supplierService.ValidateEntityExistence(request.SupplierId); if (_notificationService.HasNotifications()) { return; } var productCategory = new ProductCategory(request.CategoryName, request.SupplierId); if (productCategory.Invalid) { _notificationService.AddEntityNotifications(productCategory.ValidationResult); return; } await _productCategoryRepository.Create(productCategory); }
public bool Create(ProductCategory obj) { List <ProductCategory> lstPC = productCategoryRepository.GetAll().ToList(); string productName = obj.ProductCategoryName.Trim().ToUpper().ToString(); var check = lstPC.Where(x => x.ProductCategoryName.ToUpper() == productName).FirstOrDefault(); if (check != null) { return(false); } int?orderBy = obj.DisplayOrder; obj.DisplayOrder = orderBy == null ? (lstPC.Count() + 1) : orderBy; productCategoryRepository.Create(obj); return(true); }
public OperationResult Create(ProductCategoryCreate create) { var operation = new OperationResult(); if (ProductCategoryRepository.Exists(p => p.Name == create.Name)) { return(operation.Fail(ApplicationMessages.DuplicateRecord)); } var slug = create.Slug.Slugify(); var productCategory = new ProductCategory(create.Name, create.Description, create.Picture, create.PictureAlt, create.PictureTitle, create.Keywords, create.MetaDescription, slug); ProductCategoryRepository.Create(productCategory); ProductCategoryRepository.SaveChanges(); return(operation.Success()); }
public OperationResult Create(CreateProductCategory command) { OperationResult operationResult = new OperationResult(); string sluggish = command.Slug.Slugify(); if (_repository.Exists(c => c.Name == command.Name)) { return(operationResult.Failed(ApplicationMessages.DuplicatedRecord)); } ProductCategory productCategory = new ProductCategory(command.Name, command.Description, command.Picture, command.PictureAlt, command.PictureTitle, sluggish, command.Keywords, command.MetaDescription); _repository.Create(productCategory); _repository.SaveChanges(); return(operationResult.Succeeded("گروه محصول با موفقیت ثبت گردید")); }
public OperationResult Create(CreateProductCategory command) { var operation = new OperationResult(); if (_productCategoryRepository.Exist(x => x.Name == command.Name)) { return(operation.Failed(ApplicationMessages.DuplicatedRecord)); } var slug = command.Slug.Slugify(); var picturePath = $"{slug}"; var fileName = _fileUploader.Upload(command.Picture, picturePath); var productCategory = new ProductCategory(command.Name, command.Description, fileName, command.PictureTitle, command.PictureAlt, command.Keywords, command.MetaDescription, slug); _productCategoryRepository.Create(productCategory); _productCategoryRepository.SaveChanges(); return(operation.Succedded()); }
public OperationResult Create(CreateProductCategory command) { var operation = new OperationResult(); if (_productCategoryRepository.Exists(x => x.Name == command.Name)) { return(operation.Failed("امکان ثبت وجود ندارد ، نام تکراری است .")); } var slug = command.Name.Slugify(); var productCategory = new ProductCategory(command.Name, command.Description, command.Picture, command.PictureAlt, command.PictureTitle, command.Keywords, command.MetaDescription, slug); _productCategoryRepository.Create(productCategory); _productCategoryRepository.Save(); return(operation.Succedded()); }
public ProductCategory Create(ProductCategory productCategory) { return(_productCategoryRepository.Create(productCategory)); }
public async Task Create(ProductCategoryDto productCategoryDto) { await _productCategoryRepository.Create(productCategoryDto); }
public ProductCategory Create(ProductCategory newProductCategory) { ValidateCreate(newProductCategory); return(_productCategoryRepository.Create(newProductCategory)); }
public void Create(ProductCategory productCategory) { _productCategoryRepository.Create(productCategory); }