示例#1
0
        public async Task <int> InsertAsync(CustomerDto customerDto)
        {
            try
            {
                Customer customerToAdd = _mapper.Map <Customer>(customerDto);
                await _dbContext.AddAsync(customerToAdd);

                await _dbContext.SaveChangesAsync();

                return(customerToAdd.Id);
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "Error occurred");
                throw;
            }
        }