public async Task SaveRaceAsync(Race race) { await _readerRepository.SaveReader(race.Reader); await _readingRepository.SaveReading(race.Reading); await _readRepository.DeleteByReadingId(race.Reading.Id); await _readRepository.SaveReadRangeAsync(race.Reads); }
public void GenerateReadings() { // Generate randim values: Random rnd = new Random(); var typeNumber = rnd.Next(1, 3); // 3 is exclusive, will return 1 or 2 var randTemp = rnd.Next(-300, 301) * 0.1f; // will produce -30f to 30f var randBool = rnd.Next(1, 3) == 1 ? true : false; // true or false var reading = new Reading { Type = typeNumber == 1 ? "temperature" : "doorOpen", Value = typeNumber == 1 ? randTemp.ToString() + " C°" : randBool.ToString(), Alert = typeNumber == 1 && (randTemp <= -20 || randTemp >= 15) ? true : false, Timestamp = DateTime.Now }; readingRepository.SaveReading(reading); }