//GET: Edit author public IActionResult Edit(int id) { var editedAuthor = authorService.GetAuthorById(id); var vm = new AuthorEditVm(); vm.Name = editedAuthor.Name; return(View(vm)); }
public IActionResult Edit(AuthorEditVm vm) { var editedAuthor = new Author(); editedAuthor.ID = vm.ID; editedAuthor.Name = vm.Name; authorService.UpdateAuthor(editedAuthor); return(RedirectToAction(nameof(Index))); }
//// GET: Authors/Edit/5 public async Task <IActionResult> Edit(int id)/*int? id*/ { if (ModelState.IsValid) { var vm = new AuthorEditVm(); var author = authorservice.GetAuthorObject(id); vm.Name = author.Name; vm.Id = author.Id; return(View(vm)); } return(RedirectToAction("Error", "Home", "")); }
public async Task <IActionResult> Edit(AuthorEditVm vm) { if (ModelState.IsValid) { var editAuthor = new Author(); editAuthor.Id = vm.Id; editAuthor.Name = vm.Name; authorservice.UpdateAuthor(editAuthor); return(RedirectToAction(nameof(Index))); } return(RedirectToAction("Error", "Home", "")); }
// GET: Books/Edit/5 public async Task <IActionResult> Edit(int?id) { if (id == null) { return(NotFound()); } var author = authorService.GetAuthorById(id); if (author == null) { return(NotFound()); } var vm = new AuthorEditVm(); vm.Id = author.Id; vm.Name = author.Name; return(View(vm)); }