public static Movie ReadMovie(IDataReader reader) { Movie movie = new Movie(); movie.ID = reader.GetInt32(0); movie.Title = reader.GetString(1); movie.ReleaseDate = reader.GetDateTime(2).Date; movie.Genre = reader.GetString(3); movie.Price = reader.GetDecimal(4); return movie; }
public ActionResult Edit(Movie movie) { movie.Genre = Request.Form["genre_reselect"]; moviesOps.AddMovie(movie); if (ModelState.IsValid) { return RedirectToAction("Index"); } return View(); }
public void AddMovie(Movie newMovie) { using (SqlCommand command = new SqlCommand("Movie_Post", Connection) { CommandType = CommandType.StoredProcedure }) { command.Parameters.AddWithValue("ID", newMovie.ID); command.Parameters.AddWithValue("Title", newMovie.Title); command.Parameters.AddWithValue("ReleaseDate", newMovie.ReleaseDate); command.Parameters.AddWithValue("Genre", newMovie.Genre); command.Parameters.AddWithValue("Price", newMovie.Price); command.ExecuteNonQuery(); } }