Beispiel #1
0
        public ActionResult Excluir([FromHeader] string ibge, [FromRoute] int?id)
        {
            try
            {
                ibge = _config.GetConnectionString(Connection.GetConnection(ibge));

                //verifica tabela de lote
                var itenslote = _loterepository.GetLoteByProdutor(ibge, (int)id);
                if (itenslote.Count > 0)
                {
                    return(BadRequest(TrataErro.GetResponse("Esse fabricante não pode ser excluído pois já possui um lote vinculado a ele.", true)));
                }

                //verifica tabela de cartão de vacina
                var itenscv = _loterepository.GetLoteByProdutor(ibge, (int)id);
                if (itenscv.Count > 0)
                {
                    return(BadRequest(TrataErro.GetResponse("Esse fabricante não pode ser excluído pois já possui um cartão de vacina vinculado a ele.", true)));
                }

                _repository.Delete(ibge, (int)id);
                return(Ok());
            }
            catch (Exception ex)
            {
                var response = TrataErro.GetResponse(ex.Message, true);
                return(StatusCode((int)HttpStatusCode.InternalServerError, response));
            }
        }
 public void Delete(int Id)
 {
     _PREP.Delete(Id);
 }