public async Task <IActionResult> Edit(int id, [Bind("Id,Titulo,Descripcion,Fecha,CategoriaId")] Autor autor) { if (id != autor.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(autor); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AutorExists(autor.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["CategoriaId"] = new SelectList(_context.Set <Categoria>(), "Id", "Id", autor.CategoriaId); return(View(autor)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Nombre,Descripcion")] Categoria categoria) { if (id != categoria.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(categoria); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CategoriaExists(categoria.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(categoria)); }