Exemple #1
0
        public TidalPrediction getTidalPredictionByID(int ID)
        {
            //GET Tidal Prediction by ID
            TidalPrediction tp = new TidalPrediction();

            MySql.Data.MySqlClient.MySqlDataReader mySqlReader = null;

            String sqlString = "SELECT * FROM tidalprediction WHERE PredictionID = " + ID.ToString();

            MySql.Data.MySqlClient.MySqlCommand cmd = new MySql.Data.MySqlClient.MySqlCommand(sqlString, conn);

            mySqlReader = cmd.ExecuteReader();
            if (mySqlReader.Read())
            {
                tp.PredictionID    = mySqlReader.GetInt32(0);
                tp.Latitude        = mySqlReader.GetDouble(1);
                tp.Longitude       = mySqlReader.GetDouble(2);
                tp.StationLocation = mySqlReader.GetString(3);
                tp.Date            = mySqlReader.GetDateTime(4);
                tp.Water_Level     = mySqlReader.GetDouble(5);
                tp.Water_Level_ODM = mySqlReader.GetDouble(6);
                return(tp);
            }
            else
            {
                return(null);
            }
        }
Exemple #2
0
        public ArrayList getAllTidalPredictions()
        {
            //GET all Tidal Predictions
            ArrayList tidalPredictionArray = new ArrayList();

            MySql.Data.MySqlClient.MySqlDataReader mySqlReader = null;

            String sqlString = "SELECT * FROM tidalprediction";

            MySql.Data.MySqlClient.MySqlCommand cmd = new MySql.Data.MySqlClient.MySqlCommand(sqlString, conn);

            mySqlReader = cmd.ExecuteReader();
            while (mySqlReader.Read())
            {
                TidalPrediction tp = new TidalPrediction();
                tp.PredictionID    = mySqlReader.GetInt32(0);
                tp.Latitude        = mySqlReader.GetDouble(1);
                tp.Longitude       = mySqlReader.GetDouble(2);
                tp.StationLocation = mySqlReader.GetString(3);
                tp.Date            = mySqlReader.GetDateTime(4);
                tp.Water_Level     = mySqlReader.GetDouble(5);
                tp.Water_Level_ODM = mySqlReader.GetDouble(6);
                tidalPredictionArray.Add(tp);
            }
            return(tidalPredictionArray);
        }
        public TidalPrediction Get(string station)
        {
            TidalPredictionPersistance tpp             = new TidalPredictionPersistance();
            TidalPrediction            tidalPrediction = tpp.getTidalPredictionByStation(station);


            return(tidalPrediction);
        }
        public TidalPrediction Get(int id)
        {
            TidalPredictionPersistance tpp             = new TidalPredictionPersistance();
            TidalPrediction            tidalPrediction = tpp.getTidalPredictionByID(id);


            return(tidalPrediction);
        }
        public void Post([FromBody] TidalPrediction value)
        {
            TidalPredictionPersistance tpp = new TidalPredictionPersistance();
            int id;

            id = (int)tpp.saveTidalPrediction(value);

            value.PredictionID = id;
            //RETURN HTTP STATUS CODES

            //    //HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created);
            //    //response.Headers.Location = new Uri(Request.RequestUri, String.Format("TidalPrediction/{0}", id));
            //    //return response;
        }
Exemple #6
0
        public long saveTidalPrediction(TidalPrediction tidalPredictionToSave)
        {
            // var date = tidalPredictionToSave.Date.ToString("yyyy-MM-dd");
            //POST functionality
            String sqlString = "INSERT INTO tidalprediction (Latitude, Longitude, StationLocation, Date, Water_Level, Water_Level_ODM) " +
                               "VALUES (" + tidalPredictionToSave.Longitude + "," + tidalPredictionToSave.Latitude + ",'" + tidalPredictionToSave.StationLocation
                               + "','" + tidalPredictionToSave.Date + "'," + tidalPredictionToSave.Water_Level + "," + tidalPredictionToSave.Water_Level_ODM + ")";

            MySql.Data.MySqlClient.MySqlCommand cmd = new MySql.Data.MySqlClient.MySqlCommand(sqlString, conn);
            cmd.ExecuteNonQuery();
            long id = (int)cmd.LastInsertedId;

            return(id);
        }