Ejemplo n.º 1
0
 public ActionResult <int> AddImageSecundaryOfProduct(ImageProductDto imageProduct)
 {
     return(Execute(() =>
     {
         return _productService.AddImageSecundaryOfProduct(imageProduct);
     }));
 }
Ejemplo n.º 2
0
        public int AddImageSecundaryOfProduct(ImageProductDto imageProductDto)
        {
            var imageProducts = _genericRepository.Filter <ImageProduct>
                                    (p => p.IdProduct == imageProductDto.IdProduct).ToList();
            var newImageName    = imageProducts.Count() + 1;
            var newImageProduct = ImageProduct.Create(imageProductDto.IdProduct, newImageName);

            _genericRepository.Add(newImageProduct);
            _genericRepository.SaveChanges();
            return(newImageName);
        }
Ejemplo n.º 3
0
        public int DeleteImageSecundaryOfProduct(ImageProductDto imageProductDto)
        {
            var imageProduct = _genericRepository.Filter <ImageProduct>
                                   (p => p.Name == imageProductDto.ImageName &&
                                   p.IdProduct == imageProductDto.IdProduct && p.Active).FirstOrDefault();

            if (imageProduct == null)
            {
                throw new ApplicationException(string.Format("Image {0}_{1} no encontrada"
                                                             , imageProductDto.IdProduct, imageProductDto.ImageName));
            }
            imageProduct.Desactive();
            _genericRepository.SaveChanges();
            return(imageProductDto.ImageName);
        }