Example #1
0
        public async Task <string> InsertCoord(decimal lat, decimal lon)
        {
            using (var db = new OneContext(_connectionString))
            {
                await db.AddAsync(new Coord
                {
                    Id  = Guid.NewGuid().ToString(),
                    Lat = lat,
                    Lon = lon
                });

                await db.SaveChangesAsync();

                var res = (await db.Coords.FirstOrDefaultAsync(elem => elem.Lat == lat && elem.Lon == lon))?.Id;
                _logger.LogInformation($"coordinations is added :{lat} and {lon}");
                return(res);
            }
        }
Example #2
0
        public async Task InsertWeather(string id, WeatherDto currentWeather)
        {
            using (var db = new OneContext(_connectionString))
            {
                await db.AddAsync(new Weather
                {
                    Key      = Guid.NewGuid().ToString(),
                    Date     = currentWeather.Date,
                    FeelLike = currentWeather.FeelLike,
                    Id       = id,
                    Humidity = currentWeather.Humidity,
                    Pressure = currentWeather.Pressure,
                    Temp     = currentWeather.Temp
                });

                await db.SaveChangesAsync();

                _logger.LogInformation($"parameters of weather is added");
            }
        }