public int LogWeatherEvent(DateTime datetime, WeatherType type, bool happy, string name, string quote) { //This controller method demonstrates that DbSet Add behaves the same //as EF6: affecting every item in a [disconnected] graph with the same state //As well as Attach, Remove and the new Update. WeatherEvent wE; if (String.IsNullOrEmpty(name)) { wE = WeatherEvent.Create(datetime, type, happy); } else { wE = WeatherEvent.Create(datetime, type, happy, new List <string[]> { new[] { name, quote } }); } _context.WeatherEvents.Add(wE); var affectedRowCount = _context.SaveChanges(); return(affectedRowCount); }
private List <WeatherEvent> BuildWeatherEvents() { var events = new List <WeatherEvent> { WeatherEvent.Create(DateTime.Now, WeatherType.Sun, true), WeatherEvent.Create(DateTime.Now.AddDays(-1), WeatherType.Snow, true), WeatherEvent.Create(DateTime.Now.AddDays(-2), WeatherType.Rain, false), WeatherEvent.Create(DateTime.Now.AddDays(-3), WeatherType.Sleet, false), WeatherEvent.Create(DateTime.Now.AddDays(-4), WeatherType.Hail, false), WeatherEvent.Create(DateTime.Now.AddDays(-5), WeatherType.Snow, false), WeatherEvent.Create(DateTime.Now, WeatherType.Rain, false) }; return(events); }
private static WeatherEvent[] BuildWeatherEvents() { var events = new WeatherEvent[] { WeatherEvent.Create(DateTime.Now, WeatherType.Sun, true, new List <string[]> { new [] { "Julie", "Oh so sunny!" } }), WeatherEvent.Create(DateTime.Now.AddDays(-1), WeatherType.Snow, true), WeatherEvent.Create(DateTime.Now.AddDays(-2), WeatherType.Rain, false), WeatherEvent.Create(DateTime.Now.AddDays(-3), WeatherType.Sleet, false, new List <string[]> { new [] { "Julie", "WAT? No snow? I want to ski!" }, new [] { "Everyone in vermont", "Bring us the snow!" }, new [] { "Julie", "Ah rain! Good for the flowers!" }, }), WeatherEvent.Create(DateTime.Now.AddDays(-4), WeatherType.Hail, false), WeatherEvent.Create(DateTime.Now.AddDays(-5), WeatherType.Snow, true), WeatherEvent.Create(DateTime.Now.AddDays(-6), WeatherType.Snow, true), }; return(events); }