public ActionResult Delete(int id, FormCollection collection)
        {
            try
            {
                Movie movie = new Movie();
                MovieRepository r = new MovieRepository();
                r.Remove(id);

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
        public ActionResult Create(FormCollection collection)
        {
            try
            {
                Movie movie = new Movie();
                movie.Inventory = int.Parse(collection.GetValue("Inventory").AttemptedValue.ToString());
                movie.Overview = collection.GetValue("Overview").AttemptedValue.ToString();
                movie.ReleaseDate = collection.GetValue("ReleaseDate").AttemptedValue.ToString();
                movie.Title = collection.GetValue("Title").AttemptedValue.ToString();

                MovieRepository r = new MovieRepository();
                r.Add(movie);

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
        public void Add(Movie movie)
        {
            db.Open();
            try
            {
                SqlCommand command = new SqlCommand(
                    "insert into movies (title, overview, releaseDate, inventory) values (@title, @overview, @release_date, @inventory)",
                    this.db);
                command.Parameters.AddWithValue("@title", movie.Title);
                command.Parameters.AddWithValue("@overview", movie.Overview);
                command.Parameters.AddWithValue("@release_date", movie.ReleaseDate);
                command.Parameters.AddWithValue("@inventory", movie.Inventory);

                command.ExecuteNonQuery();
            }
            finally
            {
                db.Close();
            }
        }
        public static void SeedMovies()
        {
            // Read the contents of the file
            string s = File.ReadAllText("..\\..\\..\\AdaMovieStoreSample\\App_Data\\movies.json");

            // Parse the contents using JSON.NET
            JArray data = (JArray)JsonConvert.DeserializeObject(s);

            MovieRepository repository = new MovieRepository();

            // Process the data
            foreach (JToken token in data)
            {
                Movie m = new Movie();
                m.Title = token["title"].Value<string>();
                m.Overview = token["overview"].Value<string>();
                m.ReleaseDate = token["release_date"].Value<string>();
                m.Inventory = token["inventory"].Value<int>();

                repository.Add(m);
            }
        }
 public Movie Update(Movie movie)
 {
     throw new NotImplementedException();
 }
 public void Save(Movie movie)
 {
     throw new NotImplementedException();
 }
 public Movie Add(Movie movie)
 {
     throw new NotImplementedException();
 }
 public void Update(Movie movie)
 {
     db.Open();
     try
     {
         SqlCommand command = new SqlCommand(
             "update movies set title=@title, overview=@overview, releaseDate=@release_date, inventory=@inventory where id = @id",
             this.db);
         command.Parameters.AddWithValue("@title", movie.Title);
         command.Parameters.AddWithValue("@overview", movie.Overview);
         command.Parameters.AddWithValue("@release_date", movie.ReleaseDate);
         command.Parameters.AddWithValue("@inventory", movie.Inventory);
         command.Parameters.AddWithValue("@id", movie.Id);
         command.ExecuteNonQuery();
     }
     finally
     {
         db.Close();
     }
 }