Exemple #1
0
        private async Task UploadImages(IEnumerable <CategoryDto> source, IEnumerable <Category> target, CancellationToken cancellationToken)
        {
            foreach (var sourceCategory in source)
            {
                if (!sourceCategory.Icon.IsUpdated)
                {
                    continue;
                }
                var imageId = await _imageApi.UploadImageAsync(sourceCategory.Icon.Path, "Categories", cancellationToken);

                var imageFromDatabase = await _context.Images.FirstAsync(image => image.Id == imageId, cancellationToken);

                var targetCategories = target.First(category => category.Id == sourceCategory.Id);
                targetCategories.Icon = imageFromDatabase;
            }
        }
        private async Task UploadImages(IEnumerable <CertificateDto> source, IEnumerable <Certificate> target, CancellationToken cancellationToken)
        {
            foreach (var sourceCertificate in source)
            {
                if (!sourceCertificate.Image.IsUpdated)
                {
                    continue;
                }
                var imageId = await _imageApi.UploadImageAsync(sourceCertificate.Image.Path, "Certificates", cancellationToken);

                var imageFromDatabase = await _context.Images.FirstAsync(image => image.Id == imageId, cancellationToken);

                var targetCertificate = target.First(cert => cert.Id == sourceCertificate.Id);
                targetCertificate.Image = imageFromDatabase;
            }
        }