public ActionResult Create(Movie movie) { if (ModelState.IsValid) { movieDataHandler.Create(movie); return RedirectToAction("Index"); } return View(movie); }
public ActionResult Edit(Movie movie) { if (ModelState.IsValid) { db.Entry(movie).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } return View(movie); }
public IActionResult Create(Movie movie) { if (ModelState.IsValid) { _context.Movie.Add(movie); _context.SaveChanges(); return RedirectToAction("Index"); } return View(movie); }
public ActionResult Create(Movie movie) { if (ModelState.IsValid) { var collection = GetMoviesCollection(); collection.Insert(movie); return RedirectToAction("Index"); } return View(movie); }
public ActionResult Create(Movie movie) { if (ModelState.IsValid) { db.Movies.Add(movie); db.SaveChanges(); return RedirectToAction("Index", "Movies"); } return View(movie); }
public ActionResult Create(Movie newMovie) { if (ModelState.IsValid) { // TODO: Implement view model to add the actors. The following was tested to work OK: //Actor actor = _actorRepository.FindById(1); //newMovie.Actors = new List<Actor>(); //newMovie.Actors.Add(actor); _repository.Save(newMovie); return RedirectToAction("Index"); } else { return View(newMovie); } }
public ActionResult Delete(Movie movie) { try { // TODO: Add delete logic here DeleteMovie(movie.ID); return JavaScript("window.top.location.href ='Movies';"); } catch { return View(); } }
public ActionResult Create(FormCollection collection) { try { // TODO: Add insert logic here Movie mv=new Movie(); mv.Title = collection["Title"].ToString(); mv.ReleaseDate = Convert.ToDateTime(collection["ReleaseDate"].ToString()); mv.Genre = collection["Genre"].ToString(); mv.Price = Convert.ToDecimal(collection["Price"].ToString()); InsertMovie(mv); return RedirectToAction("Index"); } catch { return View(); } }
public ActionResult Create(Movie movie) { if (System.Web.HttpContext.Current.User.Identity.IsAuthenticated) { if (ModelState.IsValid) { movie.Useradd = System.Web.HttpContext.Current.User.Identity.Name; db.Movies.Add(movie); db.SaveChanges(); return RedirectToAction("Index"); } return View(movie); } else { return RedirectToAction("LogOn", "Account"); } }
// // GET: /Movies/Delete/5 public ActionResult Delete(int id) { List<MvcMovie.Models.Movie> lstMoview = new List<Movie>(); for (int i = 0; i < 5; i++) { Movie mv = new Movie(); mv.ID = i; mv.Title = "film " + i; mv.Genre = "film " + i; mv.Price = i; lstMoview.Add(mv); } IEnumerable<Movie> obj = from i in lstMoview where i.ID == id select i; if (obj.Count() > 0) { Movie movie = (from i in lstMoview where i.ID == id select i).First(); return Content(Boolean.TrueString); } else { return Content(Boolean.FalseString); } }
private int UpdateMovie(Movie mv) { int res = 0; Database db = DatabaseFactory.CreateDatabase("cnnString"); DbCommand dbCommand = db.GetSqlStringCommand("Update Movies set Title=@Title, ReleaseDate=@ReleaseDate,Genre=@Genre,Price=@Price where ID=@ID"); db.AddInParameter(dbCommand, "Title", DbType.String, mv.Title); db.AddInParameter(dbCommand, "ReleaseDate", DbType.Date, mv.ReleaseDate); db.AddInParameter(dbCommand, "Genre", DbType.String, mv.Genre); db.AddInParameter(dbCommand, "Price", DbType.Decimal, mv.Price); db.AddInParameter(dbCommand, "ID", DbType.Int32, mv.ID); res=db.ExecuteNonQuery(dbCommand); return res; }
private int InsertMovie(Movie mv) { int res = 0; Database db = DatabaseFactory.CreateDatabase("cnnString"); DbCommand dbCommand = db.GetSqlStringCommand("Insert Movies values(@Title,@ReleaseDate,@Genre,@Price)"); db.AddInParameter(dbCommand, "Title", DbType.String, mv.Title); db.AddInParameter(dbCommand, "ReleaseDate", DbType.Date, mv.ReleaseDate); db.AddInParameter(dbCommand, "Genre", DbType.String, mv.Genre); db.AddInParameter(dbCommand, "Price", DbType.Decimal, mv.Price); res = db.ExecuteNonQuery(dbCommand); return res; }
public ActionResult SearchIndex(string movieGenre, string searchString) { List<MvcMovie.Models.Movie> lstMoview = new List<Movie>(); for (int i = 0; i < 5; i++) { Movie mv = new Movie(); mv.ID = i; mv.Title = "film " + i; mv.Genre = "genre " + i; lstMoview.Add(mv); } var GenreLst = new List<string>(); var GenreQry = from d in lstMoview orderby d.Genre select d.Genre; GenreLst.AddRange(GenreQry.Distinct()); ViewBag.movieGenre = new SelectList(GenreLst); IEnumerable<Movie> movies = null; if (!String.IsNullOrEmpty(searchString)) { movies = lstMoview.Where(s => s.Title.Contains(searchString)); } if (string.IsNullOrEmpty(movieGenre)) return View(movies); else { return View(movies.Where(x => x.Genre == movieGenre)); } }
public Movie GetMoviesByID(int id) { List<Movie> lstMoview = new List<Movie>(); Database db = DatabaseFactory.CreateDatabase("cnnString"); DbCommand dbCommand = db.GetSqlStringCommand("select * from Movies where ID=" + id); IDataReader dr = db.ExecuteReader(dbCommand); while (dr.Read()) { Movie mv = new Movie(); mv.ID = Convert.ToInt32(dr["ID"]); mv.Title = dr["Title"].ToString(); mv.ReleaseDate = Convert.ToDateTime(dr["ReleaseDate"].ToString()); mv.Genre = dr["Genre"].ToString(); mv.Price = Convert.ToDecimal(dr["Price"].ToString()); lstMoview.Add(mv); } if (lstMoview.Count > 0) return lstMoview.First(); else { return null; } }
// GET: Movies/Edit/5 // This method is called from a button click within the browser public IActionResult Edit(int? id) { Debug.WriteLine("\n AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n id = " + id); fakeData1(); if (id == null) { return HttpNotFound(); } //Movie movie = _context.Movie.Single(m => m.ID == id); Movie movie = new Movie(); int count = movieList.Count; for(int i=0; i<count; i++) { if(id.Equals(movieList.ElementAt(i).ID)) { movie = movieList.ElementAt(i); break; } } if (movie == null) { return HttpNotFound(); } return View(movie); }
public ActionResult Edit(Movie movie) { if (ModelState.IsValid) { var collection = GetMoviesCollectionForEdit(); collection.Save(movie); return RedirectToAction("Index"); } return View(movie); }
public ActionResult Edit(Movie model) { try { Movie movie = _repository.FindById(model.ID); UpdateModel(movie); _repository.Save(movie); return RedirectToAction("Details", new { id = model.ID }); } catch (Exception) { ModelState.AddModelError("", "Edit Failure, see inner exception"); } return View(model); }
public ActionResult Edit(Movie movie) { if (ModelState.IsValid) { movie.Useradd = System.Web.HttpContext.Current.User.Identity.Name; db.Entry(movie).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index","Movies"); } return View(movie); }
private void testAdd() { Movie movie = new Movie(); movie.Title = "Gone with the Wind"; _context.Movie.Add(movie); _context.SaveChanges(); // <= Will throw server side validation exception }
public void Save(Movie movie) { throw new NotImplementedException(); }
public void testAdd() { Movie movie = new Movie(); _context.Movie.Add(movie); _context.SaveChanges(); // <= Will throw server side validation exception }
public static void CreateImageFrom(Movie movie) { Bitmap img = DownloadImageFrom(movie.ImageLink); string imgPath = Path.Combine(_currentImagePath, "movie" + movie.Id + ".jpg"); SaveImage(img, imgPath); }
public ActionResult Edit(Movie movie) { if (ModelState.IsValid) { UpdateMovie(movie); return RedirectToAction("Index"); } return View(movie); }
// // GET: /Movies/ public List<MvcMovie.Models.Movie> GetAllMovies() { List<Movie> lstMoview = new List<Movie>(); Database db = DatabaseFactory.CreateDatabase("cnnString"); DbCommand dbCommand = db.GetSqlStringCommand("select * from Movies"); IDataReader dr = db.ExecuteReader(dbCommand); while (dr.Read()) { Movie mv = new Movie(); mv.ID = Convert.ToInt32(dr["ID"]); mv.Title = dr["Title"].ToString(); mv.ReleaseDate = Convert.ToDateTime(dr["ReleaseDate"].ToString()); mv.Genre = dr["Genre"].ToString(); mv.Price = Convert.ToDecimal(dr["Price"].ToString()); lstMoview.Add(mv); } return lstMoview; }
public MovieListViewModel(IQueryable<Movie> movies) { _movies = movies; Title = "Movies"; Sample = new Movie(); }
public ActionResult Edit(Movie movie) { if (ModelState.IsValid) { var collection = GetMoviesCollectionForEdit(); try { collection.Save(movie); return RedirectToAction("Index"); } catch { serverSettings = null; throw; } } return View(movie); }