public async Task <IActionResult> Edit(int id, [Bind("ID,Titulo,FechaLanzamiento,Genero,Precio")] 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("Index")); } return(View(movie)); }
public async Task <IActionResult> Edit(Guid id, [Bind("Id,Name,SexId,Birthday,Obit,Nationality,Größe,Gewicht,PersonTypesId")] Person person) { if (id != person.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(person); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PersonExists(person.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["PersonTypesId"] = new SelectList(_context.PersonType, "Id", "Name", person.PersonTypesId); ViewData["SexId"] = new SelectList(_context.Sex, "Id", "Name", person.SexId); return(View(person)); }
public async Task <IActionResult> Edit(Guid id, [Bind("Id,Name")] Genre genre) { if (id != genre.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(genre); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!GenreExists(genre.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(genre)); }
public async Task <IActionResult> Edit(Guid id, [Bind("Id,Name,YearOfPublication,GenreId,RecordCarrierId,InStock,StorageLocationId,Added,OnWatch,Remark,Adult,ThreeD,Owner,IMDB,Ranking,LastView")] Movies movies) { if (id != movies.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(movies); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MoviesExists(movies.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["GenreId"] = new SelectList(_context.Genre.OrderBy(o => o.Name), "Id", "Name", movies.GenreId); ViewData["RecordCarrierId"] = new SelectList(_context.RecordCarrier.OrderBy(o => o.Name), "Id", "Name", movies.RecordCarrierId); ViewData["StorageLocationId"] = new SelectList(_context.StorageLocation.OrderBy(o => o.Name), "Id", "Name", movies.StorageLocationId); return(View(movies)); }
public async Task <ActionResult> Edit(Guid id, [Bind("Id,Name,PersonId")] PersonTypes personTypes) { if (id != personTypes.Id) { return(NotFound()); } if (ModelState.IsValid) { try { using (var ctx = new MvcMovieCoreContext()) { ctx.Update(personTypes); await ctx.SaveChangesAsync(); } } catch (DbUpdateConcurrencyException) { if (!PersonTypeExists(personTypes.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["PersonId"] = new SelectList(new MvcMovieCoreContext().Person, "Id", "Name"); return(View(personTypes)); }
// El atributo [Bind] es una forma de protegerse contra el acceso a datos que no se requieren cambiar. public async Task <IActionResult> Edit(int id, [Bind("ID,Title,ReleaseDate,Genre,Price,Rating")] 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)); }