public (Station station, Location locationStations) AddWeatherStationToDatabase(GeocodingAddressModelQueryParams parameters) { #region LocationOfParametersSent GeocodingAddressResponseModel locationquerycoords = _geocodingDomain.GetCoordsFromAddress(parameters).Data.FirstOrDefault(); District district = _districtDomain.GetDistrictByDistrictName(parameters.District); County county = _countiesDomain.GetCountyByCountyName(parameters.County); Location locationquery = new Location(locationquerycoords.Latitude, locationquerycoords.Longitude, "0", locationquerycoords.Name, district.Id_District, county.CountyId); _locationDomain.InsertLocationData(locationquery, district.Id_District, county.CountyId); WeatherStationWithParamsModel nearbyWeatherStation = _weatherStationDomain.FindNearByStationFromLatLong(new FindNearbyStationModel(float.Parse(locationquerycoords.Latitude, CultureInfo.InvariantCulture.NumberFormat), float.Parse(locationquerycoords.Longitude, CultureInfo.InvariantCulture.NumberFormat), 8, null)); #endregion LocationOfParametersSent //Location id nearbyWeatherStation Location locationStation = new Location(nearbyWeatherStation.Latitude.ToString().Replace(',', '.'), nearbyWeatherStation.Longitude.ToString().Replace(',', '.'), nearbyWeatherStation.Elevation.ToString().Replace(',', '.'), nearbyWeatherStation.Name.En, district.Id_District, county.CountyId); //Insert if not exists _locationDomain.InsertLocationData(locationStation, district.Id_District, county.CountyId); //Add Weather station if not exists Station stationAdded = new Station(null, nearbyWeatherStation.Name.En, nearbyWeatherStation.Country, nearbyWeatherStation.Region, nearbyWeatherStation.National, nearbyWeatherStation.Wmo, nearbyWeatherStation.Icao, nearbyWeatherStation.Iata, nearbyWeatherStation.Elevation, nearbyWeatherStation.Timezone, nearbyWeatherStation.Active, _locationDomain.RetrieveLocation(nearbyWeatherStation.Latitude.ToString().Replace(',', '.'), nearbyWeatherStation.Longitude.ToString().Replace(',', '.')).Id_Location); _weatherStationDomain.AddWeatherStationToDatabase(stationAdded); return(stationAdded, locationStation); }
public int SaveHourlyDataOfStationInDatabaseBasedOnCoords(string latitude, string longitude) { WeatherStationWithParamsModel nearbyWeatherStation = _weatherStationDomain.FindNearByStationFromLatLong(new FindNearbyStationModel(float.Parse(latitude, CultureInfo.InvariantCulture.NumberFormat), float.Parse(longitude, CultureInfo.InvariantCulture.NumberFormat), 8, null)); HourlyDataOfAPointQueryParams data = new HourlyDataOfAPointQueryParams( float.Parse(latitude, CultureInfo.InvariantCulture.NumberFormat), float.Parse(longitude, CultureInfo.InvariantCulture.NumberFormat), null, DateTime.Now.AddDays(-9).ToString("yyyy-MM-dd"), DateTime.Now.ToString("yyyy-MM-dd"), null); var hourlyData = _weatherHistoryDomain.GetHourlyDataOfPoint(data, nearbyWeatherStation.Name.En); SmartIrrigationModels.Models.DTOS.Node node = _nodeDomain.GetNodeByLatLong(latitude, longitude); return(_weatherHistoryDomain.AddHourlyDataOfPointToDatabase(hourlyData, nearbyWeatherStation.Name.En, node.IdNode)); }