// GET: BooksController/Details/5 public ActionResult Details(int id) { Book BookInList = bookRepository.Find(id); if (BookInList == null) { int BookId = id; return(View("BookNotFound", BookId)); } return(View(BookInList)); }
public ActionResult Create(BookAuthorViewModel newBookAuthor) { //Saving File Or Image string uploads = Path.Combine(Hosting.WebRootPath, "Uploads"); string FileName = newBookAuthor.File.FileName; string FullPath = Path.Combine(uploads, FileName); newBookAuthor.File.CopyTo(new FileStream(FullPath, FileMode.Create)); var author = authorRepository.Find(newBookAuthor.Book.Author.ID); var Book = newBookAuthor.Book; Book newBook = new Book { ID = Book.ID, Title = Book.Title, Description = Book.Description, Author = author, //Saving File Or Image ImageUrl = FileName }; bookRepository.Add(newBook); return(RedirectToAction("Index")); }
// GET: AuthorController/Details/5 public ActionResult Details(int id) { Author AuthorInList = bookRepository.Find(id); return(View(AuthorInList)); }