コード例 #1
0
        public async void InsertDocumentAsync()
        {
            _logger.LogInformation("InsertDocumentAsync...");
            var newItem = new Document()
            {
                Name = $"DATA_ACCESS_LAYER_TEST_{DateTime.Now:yyyyMMddHHmmssfff}.jpg",
                Type = "jpg",
                Data = await File.ReadAllBytesAsync("./TestFiles/Test.jpg")
            };

            using (var dbTransaction = await _dbConnectionFactory.BeginUserTransactionAsync(UserId))
            {
                try
                {
                    var result = await _dbContext.InsertDocumentAsync(dbTransaction, newItem);

                    dbTransaction.Commit();

                    Assert.NotNull(result);
                    Assert.NotEqual(newItem.DocumentId, result.DocumentId);
                }
                catch
                {
                    dbTransaction.Rollback();
                    throw;
                }
            }
        }
コード例 #2
0
        public async Task <Document> InsertDocumentAsync(IDbTransaction dbTransaction, Document document)
        {
            _logger.LogInformation($"Inserting document '{document}'...");
            var dalObject = _mapper.Map <DalModels.Document>(document);

            return(_mapper.Map <Document>(await _dbContext.InsertDocumentAsync(dbTransaction, dalObject)));
        }