Esempio n. 1
0
        public OperationResult Edit(EditProductacategory command)
        {
            var operation       = new OperationResult();
            var productcategory = _productCategoryRepository.Get(command.Id);

            if (productcategory == null)
            {
                return(operation.Failed(ApplicationMessages.RecordNotFound));
            }

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

            var slug = command.Slug.Slugify();

            var picturePath = $"{command.Slug}";
            var fileName    = _fileUploader.Upload(command.Picture, picturePath);

            productcategory.Edit(command.Name, command.Description, fileName,
                                 command.PictureAlt, command.PictureTitle, command.Keywords,
                                 command.MetaDescription, slug);

            _productCategoryRepository.SaveChanges();
            return(operation.Succeeded());
        }
        public JsonResult OnPostEdit(EditProductacategory command)
        {
            if (ModelState.IsValid)
            {
            }

            var result = _productCategoryApplication.Edit(command);

            return(new JsonResult(result));
        }