public IActionResult DeleteBook([FromRoute] Guid bookId)
        {
            var deleteVM = new DeleteBookViewModel {
                bookId = bookId
            };

            return(View(deleteVM));
        }
 public JsonResult OnPostDelete([FromBody] DeleteBookViewModel data)
 {
     bookDbContext.Books.Remove(new Book()
     {
         Id = data.Id
     });
     bookDbContext.SaveChanges();
     return(new JsonResult("success"));
 }
Esempio n. 3
0
        public async Task <IActionResult> Delete([FromBody] DeleteBookViewModel itemVM)
        {
            if (itemVM == null)
            {
                return(NotFound());
            }
            await _service.Delete(itemVM.Id);

            return(Ok(itemVM));
        }
        public DeleteBookViewModel GetDeliteBookViewModel(int?id)
        {
            Book book = this.Context.Books.Find(id);
            DeleteBookViewModel viewModel = Mapper.Map <Book, DeleteBookViewModel>(book);

            if (viewModel == null)
            {
                return(null);
            }

            return(viewModel);
        }
        public IActionResult DeleteBook(DeleteBookViewModel bookModel)
        {
            BookMaster bookToDelete      = _bookMasterRepository.GetBook(bookModel.BookId);
            int        deleteSuccessFlag = _bookMasterRepository.DeleteBook(bookToDelete);

            if (deleteSuccessFlag > 0)
            {
                return(RedirectToAction("Index", "Book"));
            }
            ModelState.AddModelError("", "Operation unsuccessful. Book id is not correct.");
            return(View(bookModel));
        }
Esempio n. 6
0
        public IActionResult DeleteBook(DeleteBookViewModel model)
        {
            //if (ModelState.IsValid)
            //{
            //    var user = await _userManager.GetUserAsync(User);
            //    if (await _userManager.CheckPasswordAsync(user, model.Password))
            //    {
            //        _bookRepository.DeleteBook(model.BookID);
            //    }

            //}
            _bookRepository.DeleteBook(model.BookID);
            return(RedirectToAction(nameof(ListBooks)));
        }
Esempio n. 7
0
        public ActionResult Delete(int id, DeleteBookViewModel book)
        {
            try
            {
                _book = Mapper.Map <DeleteBookViewModel, Book>(book);

                unitOfWork.Books.Delete(id);

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Esempio n. 8
0
        // GET: Admin/Books/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                throw new Exception("Invalid URL - book's id can not be null");
            }

            DeleteBookViewModel viewModel = this.bookService.GetDeliteBookViewModel(id);

            if (viewModel == null)
            {
                throw new Exception($"Invalid URL - there is no book with id {id}");
            }

            return(View(viewModel));
        }
 public IActionResult DeleteBook(DeleteBookViewModel model)
 {
     bookService.DeleteBook(model.bookId);
     return(Redirect(Url.Action("YourBooksView", "YourBooks")));
 }