public IEnumerable <Quote> GetAll() { var entityContext = new QuoterEntities(); var allQuotes = entityContext.Quotes.ToList(); return(allQuotes); }
public Quote GetOne() { HttpClient client = new HttpClient(); var response = client.GetAsync("http://iheartquotes.com/api/v1/random?format=json").Result; var quoteJson = response.Content.ReadAsStringAsync().Result; var quoteDict = JsonConvert.DeserializeObject <Dictionary <string, object> >(quoteJson); var entityContext = new QuoterEntities(); var quote = new Quote() { Content = (string)quoteDict["quote"], Source = (string)quoteDict["source"] }; entityContext.Quotes.Add(quote); entityContext.SaveChanges(); return(quote); }