public BookAuthorsPublicationHousesViewModel GetBookAuthorsPublicationHouses(int id) { Book bookModel = _unitOfWork.Books.Get(id); List <BookAuthor> allBookAuthors = _unitOfWork.BookAuthors.GetAllByBookId(id); List <Author> allAuthors = _unitOfWork.Authors.GetAll(); List <BookPublicationHouse> allBookPublicationHouses = _unitOfWork.BookPublicationHouses.GetAllByBookId(id); List <PublicationHouse> allPublicationHouses = _unitOfWork.PublicationHouses.GetAll(); var bookViewModel = Mapper.Map <Book, BookViewModel>(bookModel); var bookAuthorsRelationViewModel = Mapper.Map <List <BookAuthor>, List <BookAuthorsRelationViewModel> >(allBookAuthors); var authorViewModel = Mapper.Map <List <Author>, List <AuthorViewModel> >(allAuthors); var bookPublicationHousesRelationViewModel = Mapper.Map <List <BookPublicationHouse>, List <BookPublicationHousesRelationViewModel> >(allBookPublicationHouses); var publicationHouseViewModel = Mapper.Map <List <PublicationHouse>, List <PublicationHouseViewModel> >(allPublicationHouses); var bookAuthorsViewModel = new BookAuthorsPublicationHousesViewModel { Book = bookViewModel, BookAuthors = bookAuthorsRelationViewModel, Authors = authorViewModel, BookPublicationHouses = bookPublicationHousesRelationViewModel, PublicationHouses = publicationHouseViewModel }; return(bookAuthorsViewModel); }
public BookAuthorsPublicationHousesViewModel GetBookAuthorsPublicationHouses() { List <Author> allAuthors = _unitOfWork.Authors.GetAll(); List <PublicationHouse> allPublicationHouses = _unitOfWork.PublicationHouses.GetAll(); var authorViewModel = Mapper.Map <List <Author>, List <AuthorViewModel> >(allAuthors); var publicationHousesViewModel = Mapper.Map <List <PublicationHouse>, List <PublicationHouseViewModel> >(allPublicationHouses); var bookAuthorsViewModel = new BookAuthorsPublicationHousesViewModel { Authors = authorViewModel, PublicationHouses = publicationHousesViewModel }; return(bookAuthorsViewModel); }
public ActionResult Update(int id) { BookAuthorsPublicationHousesViewModel bookAuthors = _bookService.GetBookAuthorsPublicationHouses(id); return(View(bookAuthors)); }
public ActionResult Create() { BookAuthorsPublicationHousesViewModel bookAuthors = _bookService.GetBookAuthorsPublicationHouses(); return(View(bookAuthors)); }