//[ValidateAntiForgeryToken]
 public IActionResult Create([FromBody] Films entity)
 {
     try
     {
         if (ModelState.IsValid)
         {
             if (entity.Id == 0)
             {
                 service.Create(entity);
                 Response.StatusCode = 201;//Created
                 return(Ok(new { msg = "criado com sucesso!" }));
             }
             else
             {
                 Response.StatusCode = 404;//	Not Acceptable
                 return(null);
             }
         }
         else
         {
             Response.StatusCode = 406;//	Not Acceptable
             return(new ObjectResult("deu ruim! Mensagem: "));
         }
     }
     catch (Exception e)
     {
         Response.StatusCode = 406;//	Not Acceptable
         return(new ObjectResult("deu ruim! Mensagem: " + e.Message));
     }
 }
        protected override Task ExecuteAsync(CancellationToken stoppingToken)
        {
            var conf = new ConsumerConfig
            {
                GroupId          = "Films-consumer",
                BootstrapServers = "host.docker.internal:9094",
                AutoOffsetReset  = AutoOffsetReset.Earliest
            };

            using (var c = new ConsumerBuilder <Ignore, string>(conf).Build())
            {
                c.Subscribe("films");
                var cts = new CancellationTokenSource();
                try
                {
                    while (true)
                    {
                        var message = c.Consume(cts.Token);

                        Films F = new Films();

                        var serializeOptions = new JsonSerializerOptions
                        {
                            PropertyNamingPolicy = JsonNamingPolicy.CamelCase
                        };

                        F = JsonSerializer.Deserialize <Films>(message.Value, serializeOptions);

                        using (var scope = _serviceScopeFactory.CreateScope())
                        {
                            service = scope.ServiceProvider.GetService <IServiceFilm>();
                            service.Create(F);
                        }
                    }
                }
                catch (OperationCanceledException)
                {
                    c.Close();
                }
            }
            return(Task.CompletedTask);
        }