public async Task <ProductDto> ChangeCoverAsync(Guid productId, ChangeProductCoverDto input) { var product = await TryGetProductAsync(productId); var imageFileName = await _productPictureManager .UpdateAsync( product.CoverImage, input.CoverImage.FileName, input.CoverImage.Content); await _productManager.ChangeCoverImageAsync(product, imageFileName); var result = await Repository.UpdateAsync(product); return(await MapToGetOutputDtoAsync(result)); }
public async Task ChangeCoverASync() { var product = (await _productRepository.GetListAsync()).First(); var input = new ChangeProductCoverDto { CoverImage = new SaveFileDto() { FileName = "changeProductImage.jpg", Content = new byte[] { 1, 2, 34, 4, 5, 53, 25 } } }; var result = await _productAppService.ChangeCoverAsync(product.Id, input); result.ShouldNotBeNull(); result.CoverImage.ShouldContain(input.CoverImage.FileName); }