Ejemplo n.º 1
0
        public ActionResult ConversionImageInsert(GridCommand command, ConversionImageModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageCatalog))
            {
                return(AccessDeniedView());
            }
            var group = _categoryProductAttributeService.GetCategoryProductAttributeGroupById(model.GroupModelId);

            if (!ModelState.IsValid)
            {
                var modelStateErrors = ModelState.Values.SelectMany(x => x.Errors).Select(x => x.ErrorMessage);
                return(Content(modelStateErrors.FirstOrDefault()));
            }

            var conversionImage = new ConversionImage()
            {
                CategoryAttributeGroupId = model.GroupModelId,
                Name      = model.Name,
                PictureId = 0,
            };

            _conversionImageService.Insert(conversionImage);
            _localizedEntityService.SaveLocalizedValue(conversionImage, x => x.Name, conversionImage.Name, _workContext.WorkingLanguage.Id);
            group.ConversionImages.Add(conversionImage);

            return(ConversionImagesList(command, model.GroupModelId));
        }
Ejemplo n.º 2
0
        public void Delete(ConversionImage image)
        {
            if (image == null)
            {
                throw new ArgumentNullException("Conversion image");
            }

            _repository.Delete(image);
            _eventPublisher.EntityDeleted(image);
        }