public int InsertProductPictureMapping(Product_Picture_Mapping product_Picture_Mapping)
        {
            if (product_Picture_Mapping == null)
            {
                throw new ArgumentNullException(nameof(product_Picture_Mapping));
            }

            dbContext.Product_Picture_Mapping.Add(product_Picture_Mapping);
            dbContext.SaveChanges();
            return(product_Picture_Mapping.Id);
        }
Exemplo n.º 2
0
        public ActionResult ProductPictureAdd(int pictureId, int displayOrder, string AltAttribute, string TitleAttribute, int productId)
        {
            if (pictureId == 0)
            {
                throw new ArgumentException(nameof(pictureId));
            }

            var product = new ProductDao().GetProductById(productId);

            if (product == null)
            {
                throw new ArgumentNullException();
            }

            var picture = new PictureDao().GetPictureById(pictureId);

            if (picture == null)
            {
                throw new ArgumentNullException(nameof(pictureId));
            }

            picture.AltAttribute   = AltAttribute;
            picture.TitleAttribute = TitleAttribute;
            picture.SeoFilename    = product.MetaKeywords;

            var result = new PictureDao().UpdatePicture(picture);

            var productPictureMaping = new Product_Picture_Mapping
            {
                ProductId    = product.Id,
                PictureId    = picture.Id,
                DisplayOrder = displayOrder
            };
            int Id = new Product_Picture_MappingDao().InsertProductPictureMapping(productPictureMaping);

            if (Id > 0)
            {
                return(Json(new { Result = true }));
            }
            else
            {
                return(Json(new { Result = false }));
            }
        }