public async Task <IActionResult> Edit(int id, [Bind("LangId,Language,MovieId")] LanguageModel languageModel) { if (id != languageModel.LangId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(languageModel); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!LanguageModelExists(languageModel.LangId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["MovieId"] = new SelectList(_context.MovieModels, "MovieID", "MovieDescription", languageModel.MovieId); return(View(languageModel)); }
public async Task <IActionResult> Edit(int id, [Bind("ID,Title,ReleaseDate,Genre,Price,Test")] Movie movie) { if (id != movie.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(movie); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MovieExists(movie.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(movie)); }
public async Task <IActionResult> Edit(int id, [Bind("MovieId,Name,Director,ReleaseDate,Email,Language")] Movie movie) { if (id != movie.MovieId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(movie); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MovieExists(movie.MovieId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(movie)); }
public async Task <IActionResult> Edit(int id, [Bind("CategoryId,CategoryName,CategoryCode")] Category category) { if (id != category.CategoryId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(category); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CategoryExists(category.CategoryId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(category)); }
public async Task <IActionResult> Edit(int id, [Bind("MovieID,Category,Title,Year,Director,Rating,Edited,LentTo,Notes")] Movie movie) { if (id != movie.MovieID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(movie); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MovieExists(movie.MovieID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(movie)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,FirstName,LastName,EmailId,pwd,retypwd")] RegisterModel registerModel) { if (id != registerModel.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(registerModel); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RegisterModelExists(registerModel.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(registerModel)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name,ReleaseDate,Director,Languages,EmailID,CategoryId")] Movie movie) { if (id != movie.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(movie); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MovieExists(movie.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["CategoryId"] = new SelectList(_context.Categories, "Id", "Id", movie.CategoryId); return(View(movie)); }
public async Task <IActionResult> Update(int score, string id) { Movie movie = await _movieDB.Movies.FirstOrDefaultAsync(m => m.Id == id); movie.Rating = score; _movieDB.Update(movie); await _movieDB.SaveChangesAsync(); return(RedirectToAction("Index")); }
public MovieDTO Patch(int id, [FromBody] JsonPatchDocument <MovieDTO> moviePatch) { //get the original movie object from the DB Movie originVideo = movieRepository.GetMovieByID(id); MovieDTO movieDTO = _mapper.Map <MovieDTO>(originVideo); moviePatch.ApplyTo(movieDTO); _mapper.Map(movieDTO, originVideo); //update the movie in DB _context.Update(originVideo); _context.SaveChanges(); return(movieDTO); }
public async Task <IActionResult> Edit(int id, [Bind("ID,Title,Summary,ReleaseDate,Genre,Price,Rated,PicturePath")] Movie movie) { if (id != movie.ID) { return(NotFound()); } if (ModelState.IsValid) { try { if (movie.PictureUpload != null) { string path = Path.Combine(Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/images"), Path.GetFileName(movie.PictureUpload.FileName)); using (var stream = System.IO.File.Create(path)) { movie.PictureUpload.CopyTo(stream); } string pathInDb = "/images/" + Path.GetFileName(movie.PictureUpload.FileName); movie.PicturePath = pathInDb; } else { //Kiem bat ky hinh No Image tren internet movie.PicturePath = "/images/no-image.jpg"; } _context.Update(movie); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MovieExists(movie.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(movie)); }