public ActionResult Edit([Bind(Include = "ID,MovieName,Director,Producer,Cast,Duration,GenreID")] Movie movie) { if (ModelState.IsValid) { db.Entry(movie).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.GenreID = new SelectList(db.Genres, "GenreID", "strGenre", movie.GenreID); return(View(movie)); }
public ActionResult Edit(Movie movie) { if (ModelState.IsValid) { db.Entry(movie).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.GenreID = new SelectList(db.Genres, "GenreID", "strGenre", movie.GenreID); return(View(movie)); }
public async Task <ActionResult> Edit([Bind(Include = "MovieId,Title,ReleaseDate,Genre,Price")] Movie movie) { if (ModelState.IsValid) { db.Entry(movie).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(movie)); }
public IActionResult Edit([FromForm] Movie movie) { context.Entry(movie).State = Microsoft.EntityFrameworkCore.EntityState.Modified; var thisMovie = context.Movies.FirstOrDefault(c => c.Id == movie.Id); if (thisMovie.MovieImage == null) { if (movie.MovieImage == null) { using (var stream = new MemoryStream()) { MovieImage.CopyTo(stream); stream.Position = 0; movie.MovieImage = stream.ToArray(); } } } context.SaveChanges(); return(RedirectToAction(nameof(Index))); }
public ActionResult Edit(Movie movie) { if (movie != null) { db.Entry(movie).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } var movies = db.Movies.Find(movie.MovieId); return(View(movies)); }
public ActionResult Edit([Bind(Include = "ID,Character,ActorID,MovieID")] Role role) { if (ModelState.IsValid) { db.Entry(role).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ActorID = new SelectList(db.Actors, "ID", "Name", role.ActorID); ViewBag.MovieID = new SelectList(db.Movies, "ID", "Title", role.MovieID); return(View(role)); }
public ActionResult Edit(Movie movie) { MovieDbContext db = new MovieDbContext(); if (ModelState.IsValid) { db.Entry(movie).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("oldIndex")); } return(View(movie)); }
public ActionResult Edit([Bind(Include = "ID,Title,ReleaseDate,Genre,Price,Rating")] Movie movie) { if (ModelState.IsValid) { _db.Entry(movie).State = EntityState.Modified; _db.SaveChanges(); return(RedirectToAction("Index")); } return(View(movie)); }
public ActionResult Update(MovieViewModel movieView) { var ActorList = new List <Actor>(); foreach (var item in movieView.ActorsIds) { var actor = _db.Actors.Find(item); ActorList.Add(actor); } Movie movie = new Movie() { Id = movieView.Movie.Id, Name = movieView.Movie.Name, Plot = movieView.Movie.Plot, YearOfrelease = movieView.Movie.YearOfrelease, PosterUrl = movieView.Movie.PosterUrl, ProducerID = movieView.ProducerId }; _db.Entry(movie).State = System.Data.Entity.EntityState.Modified; _db.SaveChanges(); try { if (movieView.ActorsIds != null) { RemoveDetails(movie.Id); AddActorListToDb(movieView.ActorsIds, movie.Id); } } catch (Exception e) { Console.WriteLine(e.ToString()); } return(RedirectToAction("Index")); }
public IActionResult EditFavorite(FavoriteMovies editFavorite) { FavoriteMovies originFav = _context.FavoriteMovies.Find(editFavorite.Id); if (ModelState.IsValid) { originFav.UserRating = editFavorite.UserRating; _context.Entry(originFav).State = Microsoft.EntityFrameworkCore.EntityState.Modified; _context.Update(originFav); _context.SaveChanges(); } return(RedirectToAction("ListFavorites")); }
public ActionResult Edit(Movie movie) { if (ModelState.IsValid) { db.Entry(movie).State = EntityState.Modified; db.SaveChanges(); //var titulo = movie.Title; //Guardar en db return RedirectToAction("Index"); //return RedirectToAction("Index", "Home");//Ir al Home } return View(movie); }
public ActionResult Edit([Bind(Include = "Id,Map,Address,Phone,Email,Socical,Status,CreateDate,CreateBy")] About_Us about_Us) { if (ModelState.IsValid) { if (about_Us.CreateDate == null) { about_Us.CreateDate = DateTime.Now; } db.Entry(about_Us).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(about_Us)); }
public ActionResult Edit([Bind(Include = "Id,Text,Metatitle,Link,DisplayOrder,MenuID,Status,CreateDate,CreateBy")] SubMenu subMenu) { if (ModelState.IsValid) { if (subMenu.CreateDate == null) { subMenu.CreateDate = DateTime.Now; } db.Entry(subMenu).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(subMenu)); }
public ActionResult Edit([Bind(Include = "Id,Logo,Phone,Twitter,Facebook,Dribbble,Google,Status,CreateDate,CreateBy")] Contact contact) { if (ModelState.IsValid) { if (contact.CreateDate == null) { contact.CreateDate = DateTime.Now; } db.Entry(contact).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(contact)); }
public ActionResult Edit([Bind(Include = "Id,Name,Metatile,Avartar,Background,Year,Quality,Country,Genre,Rateting,ViewCount,Description,Content,Trailler,Video,UpSlice,UpHome,Status,CreateDate,CreateBy")] Film film) { if (ModelState.IsValid) { if (film.CreateDate == null) { film.CreateDate = DateTime.Now; } db.Entry(film).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(film)); }
public ActionResult Edit([Bind(Include = "Id,Avartar,Name,Email,Password,Phone,Class,Status,CreateDate,CreateBy")] Account account) { if (ModelState.IsValid) { if (account.CreateDate == null) { account.CreateDate = DateTime.Now; } var MaHMD5 = Common.GetMD5(account.Password); account.Password = MaHMD5; db.Entry(account).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(account)); }
public static void TestMoviesGetMovieImages(Object source, ElapsedEventArgs e) { Database.SetInitializer <MovieDbContext>(null); using (var db = new MovieDbContext()) { var moviesFromDb = db.Movies.Where(m => string.IsNullOrEmpty(m.BackdropUrl)) .OrderByDescending(m => m.Popularity).Take(40).ToList(); if (!moviesFromDb.Any()) { ExitProgram = true; return; } foreach (var movie in moviesFromDb) { try { var client = new TMDbClient("f260170a65522e5006559539ef75a2c2"); var images = client.GetMovieImagesAsync(movie.ExternalId).Result; if (images.Backdrops != null) { try { foreach (var img in images.Backdrops.OrderByDescending(b => b.VoteCount).Take(1)) { movie.BackdropUrl = "https://image.tmdb.org/t/p/original/" + img.FilePath; } } catch (Exception exception) { continue; } } } catch (Exception exception) { continue; } db.Entry(movie).State = EntityState.Modified; db.SaveChanges(); } } }
public async Task <ActionResult <MotionPictures> > UpdateMovie(MotionPictures updatedMovie) { _dbContext.Entry(updatedMovie).State = EntityState.Modified; try { await _dbContext.SaveChangesAsync(); } catch (Exception e) { if (!_dbContext.MotionPictures.Any(x => x.ID == updatedMovie.ID)) { return(NotFound("No movie with ID " + updatedMovie.ID + " was found!")); } else { return(BadRequest("Error updating record")); } } return(Ok(updatedMovie)); }
/// <summary> /// Update one movie /// </summary> /// <param name="id">Movie ID</param> /// <param name="m">Movie object</param> /// <returns>Returns -1 when not exists; 1 when success</returns> int IMovieService.Update(int id, Movie m) { _context.Entry(m).State = EntityState.Modified; try { _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MovieExists(id)) { return(-1); } else { throw; } } return(1); }
//[TestMethod] public void TestMoviesGetMovieImages() { Database.SetInitializer <MovieDbContext>(null); using (var db = new MovieDbContext()) { var moviesFromDb = db.Movies.Where(m => string.IsNullOrEmpty(m.BackdropUrl)) .OrderByDescending(m => m.Popularity).Take(40).ToList(); foreach (var movie in moviesFromDb) { var client = new TMDbClient("f260170a65522e5006559539ef75a2c2"); var images = client.GetMovieImagesAsync(movie.ExternalId).Result; foreach (var img in images.Backdrops.OrderByDescending(b => b.VoteCount).Take(1)) { movie.BackdropUrl = "https://image.tmdb.org/t/p/original/" + img.FilePath; } db.Entry(movie).State = EntityState.Modified; db.SaveChanges(); } } }
private void AddOrUpdate(Movie movie, Filter filter) { _logger.LogDebug($"Adding/updating movie. " + $"Id='{movie.Id}', Title='{movie.Title}', filter='{filter}'"); movie.LastUpdated = _dateProvider.Today; var existingMovie = _dbContext.Movies.Find(movie.Id); if (existingMovie == null) { _logger.LogDebug($"Existing record not found in DB. Creating."); movie.Filters = filter; _dbContext.Movies.Add(movie); } else { _logger.LogDebug($"Found existing record in DB. Updating."); movie.Filters = filter | existingMovie.Filters; _dbContext.Entry(existingMovie).CurrentValues.SetValues(movie); } }
public async Task <IActionResult> Putmovie(int Id, Movie movie) { movie.Id = Id; _context.Entry(movie).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MovieExists(Id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public ActionResult Update(Producer producer) { _db.Entry(producer).State = System.Data.Entity.EntityState.Modified; _db.SaveChanges(); return(RedirectToAction("Index")); }
public IActionResult EditMovie(MovieModel movie) { _DbContext.Entry(movie).State = EntityState.Modified; _DbContext.SaveChanges(); return(RedirectToAction("index")); }
public void UpdateProducer(Producer producer) { _movieDbContext.Entry(producer).State = EntityState.Modified; }
public async Task <int> PutMovie(int id, Movie movie) { _movieContext.Entry(movie).State = EntityState.Modified; return(await _movieContext.SaveChangesAsync()); }
public Task UpdateAsync(BrainstormSession session) { _movieDbContext.Entry(session).State = EntityState.Modified; return(_movieDbContext.SaveChangesAsync()); }
public IActionResult EditLocation(LocationModel locationmodel) { _DbContext.Entry(locationmodel).State = EntityState.Modified; _DbContext.SaveChanges(); return(RedirectToAction("index")); }
public IActionResult EditRating(RatingModel myrating) { _dbContext.Entry(myrating).State = EntityState.Modified; _dbContext.SaveChanges(); return(RedirectToAction("Index")); }
public void UpdateActor(Actor actor) { _movieDbContext.Entry(actor).State = EntityState.Modified; }