//public Orden ProcesarOrden()
        //{

        //}

        protected override Task ExecuteAsync(CancellationToken stoppingToken)
        {
            using (IServiceScope scope = _provider.CreateScope())
            {
                _servicio = scope.ServiceProvider.GetService <ICanastaService>();
                using (var c = new ConsumerBuilder <Ignore, string>(config).Build())
                {
                    c.Subscribe("canasta");

                    CancellationTokenSource cts = new CancellationTokenSource();
                    Console.CancelKeyPress += (_, e) =>
                    {
                        e.Cancel = true; // prevent the process from terminating.
                        cts.Cancel();
                    };

                    try
                    {
                        //while (true)
                        //{
                        //    try
                        //    {
                        var cr = c.Consume(cts.Token);
                        Console.WriteLine($"Consumed message '{cr.Value}' at: '{cr.TopicPartitionOffset}'.");
                        var canasta = JsonConvert.DeserializeObject <Canasta>(cr.Value);
                        _servicio.UpdateCanastaAsync(canasta);
                        //  var resultado = _repository.GetById(orden.id_orden);
                        //  if (resultado == null) throw new ItemNoExisteException("La orden con el siguiente id no existe: " + orden.id_estado);

                        //  resultado.id_estado = orden.id_estado;

                        //_repository.UpdateAsync(resultado);
                        return(Task.CompletedTask);
                    }
                    //    catch (ConsumeException e)
                    //    {
                    //        Console.WriteLine($"Error occured: {e.Error.Reason}");
                    //        return null;
                    //    }
                    //}
                    //}
                    catch (OperationCanceledException)
                    {
                        // Ensure the consumer leaves the group cleanly and final offsets are committed.
                        c.Close();
                        return(null);
                    }
                }
            }
        }
 public CanastaController(ICanastaService canastaService)
 {
     _servicio = canastaService;
 }