Beispiel #1
0
        private void obtenerComodidades()
        {
            SqlConnection sqlConnection = Conexion.getSqlConnection();
            SqlCommand    cmd           = new SqlCommand();
            SqlDataReader reader;

            cmd.CommandText = "SELECT * FROM COMODIDAD";
            cmd.CommandType = CommandType.Text;
            cmd.Connection  = sqlConnection;

            sqlConnection.Open();

            reader = cmd.ExecuteReader();

            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    Comodidad comodidad = new Comodidad(reader);
                    comodidades.Items.Add(comodidad, comodidadesMarcadas.Any(f => f == comodidad.id));
                }
            }

            reader.Close();
            sqlConnection.Close();
        }
Beispiel #2
0
 public string Post([FromBody] Comodidad comodidad)
 {
     if (ModelState.IsValid)
     {
         return(_comodidadRepo.Ingresar(comodidad));
     }
     return("Error");
 }
Beispiel #3
0
        public string Ingresar(Comodidad comodidad)
        {
            string        rpta = "Like";
            IDbConnection conn = Connection;

            try
            {
                DynamicParameters dp = new DynamicParameters();
                dp.Add("@nombre", comodidad.nombre);
                conn.Execute("AGREGAR_COMODIDADES", dp, commandType: CommandType.StoredProcedure);
            }
            catch (Exception e)
            {
                rpta = "Excepción encontrada: " + e.Message;
            }
            finally
            {
                conn.Close();
                conn.Dispose();
            }
            return(rpta);
        }