public ActionResult InsertarContinente(Continente _Continente) { try { SqlConnection SqlCnn; SqlCnn = Base.AbrirConexion(); SqlCommand SqlCmd = new SqlCommand("Proc_Continente_Insert", SqlCnn); SqlCmd.CommandType = CommandType.StoredProcedure; SqlCmd.Parameters.AddWithValue("@idcontinente", _Continente.idcontinente); SqlCmd.Parameters.AddWithValue("@descripcion", _Continente.descripcion); SqlCmd.ExecuteNonQuery(); Base.CerrarConexion(SqlCnn); return(Ok("Operacion realizada correctamente")); } catch (SqlException XcpSQL) { foreach (SqlError se in XcpSQL.Errors) { if (se.Number <= 50000) { return(BadRequest(se.Message)); } else { return(BadRequest("Error en Operacion de Insercion de Datos")); } } } catch (Exception Ex) { return(BadRequest(Ex.Message)); } return(Ok("")); }
public IEnumerable <Continente> ConsultarContinente() { List <Continente> lstContinente = new List <Continente>(); try { SqlConnection SqlCnn; SqlCnn = Base.AbrirConexion(); SqlCommand SqlCmd = new SqlCommand("Proc_Continente_Select", SqlCnn); SqlCmd.CommandType = CommandType.StoredProcedure; SqlDataReader rdr = SqlCmd.ExecuteReader(); while (rdr.Read()) { Continente _Continente = new Continente(); _Continente.idcontinente = (System.Int32)rdr["idcontinente"]; _Continente.descripcion = (System.String)rdr["descripcion"]; lstContinente.Add(_Continente); } Base.CerrarConexion(SqlCnn); return(lstContinente); } catch (SqlException XcpSQL) { foreach (SqlError se in XcpSQL.Errors) { if (se.Number <= 50000) { throw new Exception(se.Message); } else { throw new Exception("Error en Operacion de Consulta de Datos"); } } return(lstContinente); } catch (Exception Ex) { throw new Exception(Ex.Message); } }
public Continente BuscarContinente(System.Int32 idcontinente) { Continente _Continente = new Continente(); try { SqlConnection SqlCnn; SqlCnn = Base.AbrirConexion(); SqlCommand SqlCmd = new SqlCommand("Proc_Continente_Search", SqlCnn); SqlCmd.CommandType = CommandType.StoredProcedure; SqlCmd.Parameters.AddWithValue("@idcontinente", idcontinente); SqlDataReader rdr = SqlCmd.ExecuteReader(); while (rdr.Read()) { _Continente.idcontinente = (System.Int32)rdr["idcontinente"]; _Continente.descripcion = (System.String)rdr["descripcion"]; } Base.CerrarConexion(SqlCnn); return(_Continente); } catch (SqlException XcpSQL) { foreach (SqlError se in XcpSQL.Errors) { if (se.Number <= 50000) { throw new Exception(se.Message); } else { throw new Exception("Error en Operacion en Busqueda de Datos"); } } return(_Continente); } catch (Exception Ex) { throw new Exception(Ex.Message); } }
public ActionResult EliminarContinente([FromBody] Continente data) { return(objContinente.EliminarContinente(data)); }
public ActionResult ActualizarContinente([FromBody] Continente data) { return(objContinente.ActualizarContinente(data)); }
public ActionResult InsertarContinente([FromBody] Continente data) { return(objContinente.InsertarContinente(data)); }