public void AddImages(int productId, string[] images) { _productImageRepository.RemoveMultiple(_productImageRepository.FindAll(x => x.ProductId == productId).ToList()); foreach (var image in images) { _productImageRepository.Add(new ProductImage() { Path = image, ProductId = productId, Caption = string.Empty }); } }
public async Task AddImages(int productId, string[] images) { await _productImageRepository.RemoveMultiple((await _productImageRepository.FindAll(x => x.ProductId == productId)).AsNoTracking().AsParallel().AsOrdered().ToList()); foreach (var image in images) { await _productImageRepository.Add(new ProductImage() { Path = image, ProductId = productId, Caption = string.Empty }); } }