public async Task <IActionResult> PutProductCategories(int id, ProductCategory productCategory)
        {
            if (ModelState.IsValid)
            {
                if (id != productCategory.ProductCategoryId)
                {
                    return(BadRequest());
                }



                try
                {
                    await _productCategories.Update(productCategory);
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!await _productCategories.Exists(id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(Ok());
            }
            else
            {
                return(BadRequest(ModelState));
            }
        }
        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());
        }
Example #4
0
 public void Create(CreateProductCategory command)
 {
     if (!_productCategoryRepository.Exists(command.Name))
     {
         var productCategory = new ProductCategory(command.Name);
         _productCategoryRepository.Create(productCategory);
         _productCategoryRepository.SaveChanges();
     }
 }
Example #5
0
        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());
        }
Example #6
0
        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("گروه محصول با موفقیت ثبت گردید"));
        }
Example #7
0
        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());
        }
Example #8
0
        public OperationResult Create(CreateProductCategory command)
        {
            var operation = new OperationResult();

            if (_productCategoryRepository.Exists(x => x.Name == command.Name))
            {
                return(operation.Failed(ApplicationMessages.DuplicatedRecord));
            }


            var Slug            = command.Slug.Slugify();
            var picturePath     = $"{command.Slug}";
            var pictureName     = _fileUploader.Upload(command.Picture, picturePath);
            var productCategory = new ProductCategory(command.Name, command.Description, pictureName,
                                                      command.PictureAlt, command.PictureTitle, command.Keywords, command.MetaDescription, Slug);

            _productCategoryRepository.Create(productCategory);
            _productCategoryRepository.SaveChanges();
            return(operation.Succedded());
        }
 public bool DoesProductCategoryExist(int id)
 {
     return(_productCategoryRepository.Exists(id));
 }