/// <summary> /// Adds the item to system data collections. /// </summary> /// <param name="type">The type.</param> /// <param name="ariName">Name of the ari.</param> /// <param name="ariType">Type of the ari.</param> /// <param name="ariValue">The ari value.</param> /// <param name="temperatureF">The farenhait temperature.</param> /// <param name="temperatureC">The celsius temperature.</param> private void AddItemToSystemDataCollections(string type, string ariName, string ariType, string ariValue, double temperatureF = 0, double temperatureC = 0) { if (ariType.ToLower().Contains("temperature") || ariType.ToLower().Contains("fan")) { var minValue = "0"; var maxValue = "0"; if (ariType.ToLower().Contains("temperature")) { if (ariName.ToLower().Contains("temperature #")) { Console.WriteLine(ariName); } var temperatureRepository = new TemperatureRepository(); temperatureRepository.Add(ariName, temperatureF, temperatureC); var maxAverageTemperature = temperatureRepository.GetMaxTemperature(ariName); var minAverageTemperature = temperatureRepository.GetMinTemperature(ariName); maxValue = $"{maxAverageTemperature.ValueC} ({maxAverageTemperature.ValueF} F)"; minValue = $"{minAverageTemperature.ValueC} ({minAverageTemperature.ValueF} F)"; } _systemDataCollections[type].Add(new SystemDataItem { Name = ariName, Type = ariType, Value = ariValue, MinValue = minValue, MaxValue = maxValue }); } }
public void CadastrarTemperaturaDataInvalida() { var repo = new TemperatureRepository(config); repo.Add((TestContext.Properties["TemperaturaComDataInvalida"] as Temperature)); // Assert - Expects exception }
public void CadastrarTemperaturaSemCidade() { var repo = new TemperatureRepository(config); repo.Add((TestContext.Properties["TemperaturaSemCidade"] as Temperature)); // Assert - Expects exception }
public async Task <IHttpActionResult> PostTemperature(Temperature temperature) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } await temperatureRepository.Add(temperature); return(CreatedAtRoute("DefaultApi", new { id = temperature.Id }, temperature)); }
protected override async Task ExecuteAsync(CancellationToken stoppingToken) { while (!stoppingToken.IsCancellationRequested) { // Loading monitored cities _cities = _cityRepository.GetAll(); foreach (var city in _cities) { var temp = await _temperatureApiFacade.FindFirstOrDefault(SearchParam.ByName, city.Name); temp.CityId = city.Id; _temperatureRepository.Add(temp); } await Task.Delay(_serviceSettings.MonitoringServiceInterval * 60 * 1000, stoppingToken); } }