// GET: Users/FavoriteBooks public ActionResult FavoriteBooks() { var currentUser = this.userService.GetCurrentUser(User.Identity.GetUserId()); UserFavoriteBooksViewModel viewModel = this.userService.GetFavorite(currentUser); return(View(viewModel)); }
public UserFavoriteBooksViewModel GetFavorite(User currentUser) { var currUserFavorite = currentUser.FavoriteBooks.ToList(); UserFavoriteBooksViewModel viewModel = Mapper.Map <User, UserFavoriteBooksViewModel>(currentUser); ICollection <BooksViewModel> favoriteViewModel = Mapper.Map <ICollection <Book>, ICollection <BooksViewModel> >(currUserFavorite); viewModel.FavoriteBooks = favoriteViewModel; return(viewModel); }