using System;
using System.ComponentModel.DataAnnotations;

namespace MeteoWebApp.Models
{
	public class LastMeasurement
	{
		public DateTime Timestamp { get; set; }
		public string Name{ get; set; }
		public float Temperature { get; set; }
		public float DewPoint { get; set; }
		public float TemperatureFeelsLike { get; set; }
		public float Humidity { get; set; }
		public float Pressure { get; set; }
		public float SeaLevelPressure { get; set; }
		public float WindSpeed { get; set; }
		[StringLength(3)]
		public string WindAngleStr { get; set; }
		public float RainAmount5M { get; set; }
		public float RainAmount24H { get; set; }
		public float RainAmount7D { get; set; }
		public float UvIndex { get; set; }
		[StringLength(16)]
		public string SoilTempDepth1 { get; set; }
		public float SoilTemp1 { get; set; }
		[StringLength(16)]
		public string SoilTempDepth2 { get; set; }
		public float SoilTemp2 { get; set; }
		[StringLength(16)]
		public string SoilTempDepth3 { get; set; }
		public float SoilTemp3 { get; set; }
		[StringLength(16)]
		public string SoilMoistureDepth1 { get; set; }
		public float SoilMoisture1 { get; set; }
		[StringLength(16)]
		public string SoilMoistureDepth2 { get; set; }
		public float SoilMoisture2 { get; set; }
		[StringLength(16)]
		public string SoilMoistureDepth3 { get; set; }
		public float SoilMoisture3 { get; set; }
		public float BatteryVoltage { get; set; }



		public LastMeasurement()
		{

		}

		/* Contructor - fill data from parameters */
		public LastMeasurement(Measurement measurement, Station station)
		{

			this.Timestamp = measurement.Timestamp;
			this.Name = station.Name;
			this.Temperature = measurement.Temperature;
			this.DewPoint = measurement.DewPoint;
			this.TemperatureFeelsLike = measurement.TemperatureFeelsLike;
			this.Humidity = measurement.Humidity;
			this.Pressure = measurement.Pressure;
			this.SeaLevelPressure = measurement.SeaLevelPressure;
			this.WindSpeed = measurement.WindSpeed;
			this.WindAngleStr = measurement.WindAngleStrCzech();
			this.RainAmount5M = measurement.RainAmount;
			this.RainAmount24H = 0; // This is filled later
			this.RainAmount7D = 0; // This is filled later
			this.UvIndex = measurement.UvIndex;
			this.SoilTempDepth1 = measurement.SoilTempDepth1;
			this.SoilTemp1 = measurement.SoilTemp1;
			this.SoilTempDepth2 = measurement.SoilTempDepth2;
			this.SoilTemp2 = measurement.SoilTemp2;
			this.SoilTempDepth3 = measurement.SoilTempDepth3;
			this.SoilTemp3 = measurement.SoilTemp3;
			this.SoilMoistureDepth1 = measurement.SoilMoistureDepth1;
			this.SoilMoisture1 = measurement.SoilMoisture1;
			this.SoilMoistureDepth2 = measurement.SoilMoistureDepth2;
			this.SoilMoisture2 = measurement.SoilMoisture2;
			this.SoilMoistureDepth3 = measurement.SoilMoistureDepth3;
			this.SoilMoisture3 = measurement.SoilMoisture3;
			this.BatteryVoltage = measurement.BatteryVoltage;
		}
	}
}
