示例#1
0
        public async Task <bool> AddImage(int productId, Image image)
        {
            var product = await _ctx.Products.FindAsync(productId);

            if (product is null)
            {
                throw new ArgumentException("There is no such product.");
            }

            image.ProductId = productId;

            var entityImage = Projections.DomainImageToEntityImage(image);

            _ctx.Images.Add(entityImage);
            return((await _ctx.SaveChangesAsync()) > 0);
        }