Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void smth()
- {
- using (MoviesDBEntities context = new MoviesDBEntities())
- {
- Movie movie = new Movie
- {
- Title = "hlen",
- Descr = "HUI",
- Rating = 5,
- Stars = "Ya",
- Director = "Pidoras s gori"
- };
- context.Movies.Add(movie);
- context.SaveChanges();
- }
- }
- private void AddEntity()
- {
- string apiKey = "e5df3688";
- string baseUrl = $"http://www.omdbapi.com/?apikey={apiKey}";
- string name = Title.Text.ToLower();
- var sb = new StringBuilder(baseUrl);
- sb.Append($"&t={name}");
- var request = WebRequest.Create(sb.ToString());
- request.Timeout = 1000;
- request.Method = "GET";
- request.ContentType = "application/json";
- string result = string.Empty;
- try
- {
- using (var response = request.GetResponse())
- {
- using (var stream = response.GetResponseStream())
- {
- using (var reader = new StreamReader(stream, Encoding.UTF8))
- {
- result = reader.ReadToEnd();
- }
- }
- }
- }
- catch (WebException e)
- {
- MessageBox.Show(e.ToString());
- }
- catch (Exception e)
- {
- MessageBox.Show(e.ToString());
- }
- MessageBox.Show(result);
- dynamic json = JObject.Parse(result);
- string title = json.Plot;
- var option = MessageBox.Show(title, "Add this title to library", MessageBoxButton.YesNo);
- if (option == MessageBoxResult.Yes)
- {
- }
- }
- private void Button_Click(object sender, RoutedEventArgs e)
- {
- smth();
- AddEntity();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement