// GET: Book/Edit/5 public ActionResult Edit(int id) { var model = mapper.Map <EditBookViewModel>(books.GetById(id)); model.SetAuthors(authors.GetAll().ToList()); model.SetCities(cities.GetAll().ToList()); model.SetPublishings(publishings.GetAll().ToList()); return(View(model)); }
public IHttpActionResult GetAllAuthors() { var model = mapper.Map <ICollection <IndexAuthorViewModel> >(authors.GetAll()); if (model.Count == 0) { return(NotFound()); } return(Ok(model.ToList())); }
public ActionResult GetBook(int bookId) { Book book = _bookLogic.GetById(bookId); List <AuthorsAndBooks> authorId = _authorsAndBooksLogic.GetAll().FindAll(ab => ab.BookID == bookId); List <Author> authors = _authorLogic.GetAll().FindAll(a => authorId.Exists(ab => ab.AuthorID == a.AuthorID)); List <ListGenre> listGenres = _listGenreLogic.GetAll().FindAll(lg => lg.BookID == bookId); List <Genre> genres = _genreLogic.GetAll().FindAll(g => listGenres.Exists(lg => lg.GenreID == g.GenreID)); ViewData["ph"] = _publishingHouseLogic.GetAll().Find(p => p.PublishingHouseID == book.PublishingHouseID) .PublishingHouseTitle; ViewData["author"] = string.Join(", ", authors.Select(a => a.AuthorFullName).ToArray()); ViewData["genre"] = string.Join(", ", genres.Select(g => g.GenreTitle).ToArray()); ; return(View(_mapper.Map <BookModel>(book))); }
public CreateBookViewModel(IAuthorLogic authorLogic, ICityLogic cityLogic, IPublishingLogic publishingLogic) { this.Authors = SetAuthors(authorLogic.GetAll().ToList()); this.Cities = SetCities(cityLogic.GetAll().ToList()); this.Publishings = SetPublishings(publishingLogic.GetAll().ToList()); }
// GET: Author public ActionResult Index() { var model = mapper.Map <IEnumerable <IndexAuthorViewModel> >(authorLogic.GetAll()); return(View(model)); }