예제 #1
0
        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;
        }
예제 #2
0
 //GET MOVIES TO DB
 public async Task AddAsync(Movie m){
     Movies.Add(m);
     await db.SaveChangesAsync();
 }
예제 #3
0
 //REMOVE A MOVIE FROM DB
 public void Remove(Movie m){
     if (m != null) {
         db.Movies.Remove(m);
     }
 }
예제 #4
0
 //SET ENTITY STATE
 public async Task SetEntityState(Movie m, EntityState state){
     db.Entry(m).State = state;
     await db.SaveChangesAsync();
 }