public void Append(CityWeather city) { _cities?.Add(city); _message.Publish(new WeatherRequest { City = city.Name }); }
public Response AddCity(City city) { using (var ctx = _database.Context()) { try { var cityWeather = new CityWeather { Name = city.Name.ToUpper(), JSON = "", Date = DateTime.MinValue, }; ctx.CityWeathers.Add(cityWeather); ctx.SaveChanges(); _updateService.Append(cityWeather); return(RawJSON("{}")); } catch (DbUpdateException) { return(RawJSON("{\"error\": \"City already exists\"}", HttpStatusCode.Conflict)); } } }