예제 #1
0
        public async Task <ActionResult <ShippingMethod> > UpdateShippingMethod([FromBody] ShippingMethod shippingMethod)
        {
            await _shippingMethodsService.SaveChangesAsync(new[] { shippingMethod });

            return(Ok(shippingMethod));
        }
예제 #2
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() == "ShippingMethods")
                            {
                                await reader.DeserializeJsonArrayWithPagingAsync <ShippingMethod>(_jsonSerializer, _batchSize, items => _shippingMethodsService.SaveChangesAsync(items.ToArray()), processedCount =>
                                {
                                    progressInfo.Description = $"{ processedCount } shipping methods have been imported";
                                    progressCallback(progressInfo);
                                }, cancellationToken);
                            }
                        }
                    }
                }
        }