コード例 #1
0
        private async Task ProcessProdutoVendidoQueue(Message message)
        {
            var options = new DbContextOptions <EstoqueServiceContext>();

            using (var _db = new EstoqueServiceContext(options))
            {
                try
                {
                    var produto = JsonConvert.DeserializeObject <Produto>(Encoding.UTF8.GetString(message.Body));
                    _db.Entry(produto).State = EntityState.Modified;
                    await _db.SaveChangesAsync();

                    _logger.LogInformation($"Produto atualizado - QueueName: {QueueName}");
                }
                catch (System.Exception)
                {
                    throw;
                }
            }
        }
コード例 #2
0
 public ProdutoService(EstoqueServiceContext db) => _db = db;