예제 #1
0
        //GET: Edit author
        public IActionResult Edit(int id)
        {
            var editedAuthor = authorService.GetAuthorById(id);
            var vm           = new AuthorEditVm();

            vm.Name = editedAuthor.Name;
            return(View(vm));
        }
예제 #2
0
        public IActionResult Edit(AuthorEditVm vm)
        {
            var editedAuthor = new Author();

            editedAuthor.ID   = vm.ID;
            editedAuthor.Name = vm.Name;
            authorService.UpdateAuthor(editedAuthor);
            return(RedirectToAction(nameof(Index)));
        }
예제 #3
0
 //// 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", ""));
 }
예제 #4
0
        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", ""));
        }
예제 #5
0
        // 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));
        }