Пример #1
0
        public async Task <IList <Record> > BatchWriteAsync(string country, IList <Record> records)
        {
            s_helper.Check <StorageClientException>(records == null, Messages.Storage.s_errNullBatch);
#pragma warning disable CA1062
            foreach (var record in records)
#pragma warning restore CA1062
            {
                s_helper.Check <StorageClientException>(record == null, Messages.Storage.s_errNullRecord);
                s_helper.Check <StorageClientException>(string.IsNullOrEmpty(record.RecordKey),
                                                        Messages.Storage.s_errNullRecordKey);
            }

            if (records.Count > 0)
            {
                await _dao.CreateBatchAsync(country?.ToLowerInvariant(),
                                            _transformer.GetTransferRecordList(records))
                .ConfigureAwait(false);

                return(records);
            }

            s_log.Error(Messages.Storage.s_errEmptyBatch);
            throw new StorageClientException(Messages.Storage.s_errEmptyBatch);
        }