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 (_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()); }