// GET: Books/Edit/5 public ActionResult Edit(int id) { var book = bookRepo.Find(id); var autherId = book.Auther == null? book.Auther.Id = 0 : book.Auther.Id; //var autherId = book.Auther.Id; var ViewModel = new BookAutherViewModel { BookId = book.Id, Titel = book.Tital, AutherId = autherId, Authers = autherRepo.List().ToList(), ImageUrl = book.ImageUrl }; return(View(ViewModel)); }
// GET: BookController/Edit/5 public ActionResult Edit(int id) { var book = bookRepository.Find(id); var viewModel = new BookAuthorViewModel { BookId = book.Id, Title = book.Title, Description = book.Description, AuthorId = book.Author.Id, Authors = authorRepository.List() }; return(View(viewModel)); }
//List<Author> FillSelectList() //{ // var authors = authorRepo.List().ToList(); // authors.Insert(0, new Author { ID = -1, FullName = "--- please select an author ---" }); // return authors; //} BookAuthorViewModel GetAllAuthors() { var authors = authorRepo.List().ToList(); authors.Insert(0, new Author { ID = -1, FullName = "--- please select an author ---" }); var model = new BookAuthorViewModel() { Authors = authors }; return(model); }
// GET: HomeController1 public ActionResult Index() { var authors = _authorRepository.List(); return(View(authors)); }
// GET: BookController public ActionResult Index() { var books = bookRepository.List(); return(View(books)); }
// GET: Default public ActionResult Index() { var authers = autherRepo.List(); return(View(authers)); }