/// <summary> /// Initializes a new instance of the <see cref="WeatherInfoCI"/> class. /// </summary> /// <param name="dto">The <see cref="WeatherInfoDTO"/> used to create new instance</param> internal WeatherInfoCI(WeatherInfoDTO dto) { Guard.Argument(dto, nameof(dto)).NotNull(); TemperatureCelsius = dto.TemperatureCelsius; Wind = dto.Wind; WindAdvantage = dto.WindAdvantage; Pitch = dto.Pitch; WeatherConditions = dto.WeatherConditions; }
/// <summary> /// Initializes a new instance of the <see cref="WeatherInfoCI" /> class. /// </summary> /// <param name="dto">The <see cref="WeatherInfoDTO" /> used to create new instance</param> internal WeatherInfoCI(WeatherInfoDTO dto) { Contract.Requires(dto != null); TemperatureCelsius = dto.TemperatureCelsius; Wind = dto.Wind; WindAdvantage = dto.WindAdvantage; Pitch = dto.Pitch; WeatherConditions = dto.WeatherConditions; }
public ActionResult <WeatherDTO> Get(string id) { const int days = 5; var ret = new WeatherDTO(); try { var weatherInfoList = _repository.LoadWeatherInfo(id, days); var last = _sharedData.LastSensorData.Where(z => z.Key == id).FirstOrDefault(); ret.SenderMAC = id; ret.SenderName = last.Value.SenderName ?? ""; ret.Temperature = last.Value.Temperature; ret.Humidity = last.Value.Humidity; ret.Date = DateTime.Now.ToString("ddd, dd MMM"); var weatherInfoHistory = new WeatherInfoDTO[days]; int i = 0; foreach (var item in weatherInfoList) { weatherInfoHistory[i] = new WeatherInfoDTO(); weatherInfoHistory[i].Max = item.Max; weatherInfoHistory[i].Min = item.Min; weatherInfoHistory[i].DateISO = item.Day; weatherInfoHistory[i].DateOfWeek = DateTime.Parse(weatherInfoHistory[i].DateISO).ToString("ddd"); i++; } for (int y = i; y < days; y++) { weatherInfoHistory[y] = new WeatherInfoDTO(); } ret.WeatherInfo = weatherInfoHistory; } catch (Exception ex) { Logger.Error("ProcessData", "Error on execution. " + ex.Message); } return(ret); }
public void WeatherInfoTest() { var weatherInfo = new weatherInfo { pitch = "my pitch", temperature_celsius = 40, temperature_celsiusSpecified = true, weather_conditions = "my weather conditions", wind = "strong", wind_advantage = "none" }; var weatherInfoDTO = new WeatherInfoDTO(weatherInfo); var weatherInfoCI = new WeatherInfoCI(weatherInfoDTO); Assert.IsNotNull(weatherInfoCI); Assert.AreEqual(weatherInfo.pitch, weatherInfoCI.Pitch); Assert.AreEqual(weatherInfo.temperature_celsius, weatherInfoCI.TemperatureCelsius); Assert.AreEqual(weatherInfo.weather_conditions, weatherInfoCI.WeatherConditions); Assert.AreEqual(weatherInfo.wind, weatherInfoCI.Wind); Assert.AreEqual(weatherInfo.wind_advantage, weatherInfoCI.WindAdvantage); }