public async Task InitializeAPIAsync() { var url = "https://api.trendlog.io/V1/channels/20/feeds/p1_cnt?apikey=GUZ5VO4I39GM"; //BAD CONDUCT string responseString = await GetResponseAsync(url); var model = JsonConvert.DeserializeObject <RootObject>(responseString); foreach (var item in model.channel.feeds) { _context.Feeds.Add(item); } _context.SaveChanges(); foreach (var item in model.channel.feeds[0].points) { _context.Points.Add(item); } _context.SaveChanges(); }
public TrendlogController(TrendlogContext context) { _context = context; if (_context.Channels.Count() == 0) { // Create a new TodoItem if collection is empty, // which means you can't delete all TodoItems. _context.Channels.Add(new Channel { Name = "Item1" }); _context.SaveChanges(); } }