public IActionResult EditBook(BookEditInputModel bookEditInputModel) { ViewData["Genres"] = GetGenres(); if (ModelState.IsValid) { _bookService.EditBook(bookEditInputModel); return(RedirectToAction("Index", "Home")); } return(View()); }
public IActionResult Edit(BookEditInputModel model, string bookId) { if (!ModelState.IsValid) { return(this.View(model)); } var libraryId = this.userService.GetUserLibraryId(this.User.Identity.Name); var mappedModel = this.mapper.Map <EditBookDto>(model); this.bookService.EditBookById(bookId, mappedModel, libraryId); base.UpdateBooksInCache().Wait(); return(this.RedirectToAction("All")); }
public void EditBook(BookEditInputModel bookEditInputModel) { var book = _bookRepo.GetBookEntity(bookEditInputModel.Id); book.ISBN = bookEditInputModel.ISBN; book.Language = bookEditInputModel.Language; book.Image = bookEditInputModel.Image; book.Title = bookEditInputModel.Title; book.Genre = bookEditInputModel.Genre; book.Info = bookEditInputModel.Info; book.AuthorId = (int)bookEditInputModel.AuthorId; book.Publisher = bookEditInputModel.Publisher; book.PageCount = bookEditInputModel.PageCount; book.ReleaseYear = (int)bookEditInputModel.ReleaseYear; book.Price = (double)bookEditInputModel.Price; book.Rating = bookEditInputModel.Rating; book.RatingCount = bookEditInputModel.RatingCount; book.Stock = bookEditInputModel.Stock; _bookRepo.UpdateBook(book); }