Exemplo n.º 1
0
        public JsonResult OnPostCreate(CreateProductCategory command)
        {
            var result = _productCategoryApplication.Create(command);

            return(new JsonResult(result));
            //return RedirectToPage("./Index");
        }
        public OperationResult Create(CreateProductCategory command)
        {
            OperationResult operationResult = new OperationResult();

            if (_productCategoryRepo.Exists(c => c.Name == command.Name))
            {
                return(operationResult.Failed(ApplicationMessage.duplicated));
            }


            var Slug = command.Slug.Slugify();


            var picpath = $"{command.Slug}";



            var Picturename = _fileUploader.Upload(command.picture, picpath);


            var ProductCategory = new ProductCategory(command.Name, command.Description, Picturename, command.pictureAlt,
                                                      command.pictureTitle, command.KeyWords, command.MetaDescription, Slug);

            _productCategoryRepo.Create(ProductCategory);
            _productCategoryRepo.Save();
            return(operationResult.Succeeded());
        }
Exemplo n.º 3
0
 public void Create(CreateProductCategory command)
 {
     if (!_productCategoryRepository.Exists(command.Name))
     {
         var productCategory = new ProductCategory(command.Name);
         _productCategoryRepository.Create(productCategory);
         _productCategoryRepository.SaveChanges();
     }
 }
Exemplo n.º 4
0
        public Form Show()
        {
            var repository    = new SQLServerCategoryRepository();
            var producCreator = new ProductCategoryCreator(repository);
            var handler       = new ProductCategoryCommandHandler(producCreator);

            var data = new Dictionary <string, object>
            {
                { "CreatorHandler", handler }
            };

            var form = new CreateProductCategory(data);

            return(form);
        }
        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());
        }
Exemplo n.º 8
0
        public async Task <IActionResult> Create([FromBody] CreateProductCategory data, [FromHeader] string CompanyId)
        {
            if (ModelState.IsValid)
            {
                data.CreatedBy = User.Claims.FirstOrDefault(s => s.Type == "userName").Value;
                data.CompanyId = CompanyId;
                var result = await _createProductCategoryRequestClient.Request(data);

                if (result.Id != "-1")
                {
                    return(Ok(result));
                }
                else
                {
                    return(BadRequest("categoryCodeExisted"));
                }
            }
            return(BadRequest(ModelState));
        }
        public IApiResult Update(CreateProductCategory operation)
        {
            var result = operation.ExecuteAsync().Result;

            if (result is ValidationsOutput)
            {
                return(new ApiResult <List <ValidationItem> >()
                {
                    Data = ((ValidationsOutput)result).Errors
                });
            }
            else
            {
                return(new ApiResult <object>()
                {
                    Status = ApiResult <object> .ApiStatus.Success
                });
            }
        }
Exemplo n.º 10
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("گروه محصول با موفقیت ثبت گردید"));
        }
        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());
        }
Exemplo n.º 12
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());
        }
Exemplo n.º 13
0
        public JsonResult OnPostCreate(CreateProductCategory command)
        {
            var result = _productCategoryApplication.Create(command);

            return(new JsonResult(result));
        }
Exemplo n.º 14
0
 public IActionResult OnPost(CreateProductCategory command)
 {
     _productCategoryApplication.Create(command);
     return(RedirectToPage("Index"));
 }
Exemplo n.º 15
0
        public IActionResult OnGetCreate()
        {
            var commnd = new CreateProductCategory();

            return(Partial("./Create", commnd));
        }