public ActionResult Excluir([FromHeader] string ibge, [FromRoute] int?id) { try { ibge = _config.GetConnectionString(Connection.GetConnection(ibge)); var itenscoleta = _repository.GetColetaByVisita(ibge, (int)id); foreach (var item in itenscoleta) { _repository.DeleteColeta(ibge, item.id); } _repository.DeleteVisita(ibge, (int)id); return(Ok()); } catch (Exception ex) { var response = TrataErro.GetResponse(ex.Message, true); return(StatusCode((int)HttpStatusCode.InternalServerError, response)); } }