Exemple #1
0
        public void DeleteReadingTest()
        {
            var command = "SELECT * FROM Readings " +
                          "WHERE TimeStamp IN(SELECT MAX(TimeStamp) FROM Readings)";
            var latestReading = SqlOperator.GetReadings(command)[0];

            SqlOperator.DeleteReading(latestReading.Id);
            var command2 = $"SELECT * FROM Readings WHERE Id={latestReading.Id}";
            var readings = SqlOperator.GetReadings(command2);

            Assert.IsTrue(readings.Count == 0);
        }
Exemple #2
0
        public IHttpActionResult DeleteReading(int id)
        {
            var command  = $"SELECT * FROM Readings WHERE Id={id}";
            var readings = SqlOperator.GetReadings(command);

            if (readings.Count == 0)
            {
                return(NotFound());
            }
            SqlOperator.DeleteReading(id);

            return(Ok(readings[0]));
        }