Exemple #1
0
        public async Task DoImportAsync(Stream inputStream, Action <ExportImportProgressInfo> progressCallback, ICancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();

            var progressInfo = new ExportImportProgressInfo();

            using (var streamReader = new StreamReader(inputStream))
                using (var reader = new JsonTextReader(streamReader))
                {
                    while (reader.Read())
                    {
                        if (reader.TokenType == JsonToken.PropertyName)
                        {
                            if (reader.Value.ToString() == "TaxProviders")
                            {
                                await reader.DeserializeJsonArrayWithPagingAsync <TaxProvider>(_jsonSerializer, _batchSize, items => _taxProviderService.SaveChangesAsync(items.ToArray()), processedCount =>
                                {
                                    progressInfo.Description = $"{ processedCount } tax providers have been imported";
                                    progressCallback(progressInfo);
                                }, cancellationToken);
                            }
                        }
                    }
                }
        }
        public async Task <ActionResult <TaxProvider> > UpdateTaxProvider([FromBody] TaxProvider taxProvider)
        {
            await _taxProviderService.SaveChangesAsync(new[] { taxProvider });

            return(Ok(taxProvider));
        }