示例#1
0
        public async Task <IActionResult> AddCopy(BookCopyAddVm vm)
        {
            if (ModelState.IsValid)
            {
                var BookCopy = new BookDetails();
                BookCopy.AuthorID    = vm.AuthorId;
                BookCopy.Description = vm.Description;
                BookCopy.ISBN        = vm.ISBN;
                BookCopy.Title       = vm.Title;
                BookCopy.ID          = vm.Id;
                copyservice.AddCopy(vm.Amount, BookCopy);
                return(RedirectToAction(nameof(Index)));
            }

            return(RedirectToAction("Error", "Home", ""));
        }
示例#2
0
 public async Task <IActionResult> AddCopy(int id)/*int? id*/
 {
     if (ModelState.IsValid)
     {
         var vm   = new BookCopyAddVm();
         var book = bookservice.GetBook(id);
         vm.Title         = book.Title;
         vm.Description   = book.Title;
         vm.ISBN          = book.ISBN;
         vm.AuthorId      = book.AuthorID;
         vm.Id            = book.ID;
         vm.CurrentCopies = book.Copies.Count;
         vm.Author        = authorService.GetAuthor(book.AuthorID);
         return(View(vm));
     }
     return(RedirectToAction("Error", "Home", ""));
 }