public List<Movie> Parse(HttpWebResponse webResponse) { List<Movie> ret = new List<Movie>(); using (var reader = new StreamReader(webResponse.GetResponseStream())) { JavaScriptSerializer js = new JavaScriptSerializer(); var data = js.Deserialize<dynamic>(reader.ReadToEnd()); foreach (var dataObj in data["Search"]) { Movie newMovie = new Movie(); newMovie.Title = dataObj["Title"]; newMovie.Year = dataObj["Year"]; newMovie.imdbID = dataObj["imdbID"]; newMovie.Poster = dataObj["Poster"]; newMovie.Type = DataHelper.GetOMDBObjType(dataObj["Type"]); ret.Add(newMovie); } } return ret; }
//GET MOVIES TO DB public async Task AddAsync(Movie m){ Movies.Add(m); await db.SaveChangesAsync(); }
//REMOVE A MOVIE FROM DB public void Remove(Movie m){ if (m != null) { db.Movies.Remove(m); } }
//SET ENTITY STATE public async Task SetEntityState(Movie m, EntityState state){ db.Entry(m).State = state; await db.SaveChangesAsync(); }