Exemple #1
0
        public ActionResult Inserir([FromHeader] string ibge, [FromBody] Visita model)
        {
            try
            {
                ibge     = _config.GetConnectionString(Connection.GetConnection(ibge));
                model.id = _repository.GetNewIdVisita(ibge);
                _repository.InsertVisita(ibge, model);

                foreach (var item in model.itens)
                {
                    item.id_visita = model.id;
                    item.id        = _repository.GetNewIdColeta(ibge);
                    _repository.InsertColeta(ibge, item);
                }

                return(Ok(model));
            }
            catch (Exception ex)
            {
                var response = TrataErro.GetResponse(ex.Message, true);
                return(StatusCode((int)HttpStatusCode.InternalServerError, response));
            }
        }