public ActionResult AuthorPage(int?page, string name) { BlogEntities db = new BlogEntities(); AuthorPageViewModel viewModel = new AuthorPageViewModel(); string sql = ""; if (name == null || name == "") { return(RedirectToAction("ListPost")); } List <PostViewModel> tmpList = db.POSTs.Where(c => c.CREATED_USER == name).Select(c => new PostViewModel { TITLE = c.TITLE, IMAGE_COVER = c.IMAGE_COVER, SLUG = c.SLUG, CREATED_DATE = c.CREATED_DATE, CREATED_USER = c.CREATED_USER, MAIN_TAG = c.MAIN_TAG, META_DESC = c.META_DESC }).ToList(); int pageSize = 5; int pageNumber = (page ?? 1); viewModel.ListPost = tmpList.ToPagedList(pageNumber, pageSize); viewModel.User = db.PAGE_USER.FirstOrDefault(c => c.USERNAME == name); if (viewModel.User == null || viewModel.ListPost == null) { return(RedirectToAction("ListPost")); } return(View(viewModel)); }
// GET: Author public ActionResult Index() { AuthorPageViewModel viewModel = new AuthorPageViewModel(); viewModel.ItemList = _authorService.GetAllAuthors(); return(View(viewModel)); }
public ActionResult Index() { SetListsForViews(); Book book = new Book(); AuthorPageViewModel author = new AuthorPageViewModel(); //ViewBag.List = author.BooksResult.ToList(); author.BooksResult = book.GetAll(); return(View(author)); }
public AuthorPageViewModel GetAuthorPageViewModel(int authorId) { var model = new AuthorPageViewModel { Author = Get(authorId), NewsCount = _newsService.FindBy(news => news.AuthorId == authorId).Count(), CommentCount = 0 }; return(model); }
public ActionResult Index(AuthorPageViewModel author) { SetListsForViews(); if (ModelState.IsValid) { Book book = new Book(); var books = book.GetAll(); if (!String.IsNullOrEmpty(author.Keyword)) { books = books.Where(b => b.Title.ToLower().Contains(author.Keyword.ToLower())).ToList(); } author.BooksResult = books; } return(View(author)); }
private void OnPageLoaded(object sender, RoutedEventArgs e) { this.ViewModel = DataContext as AuthorPageViewModel; ViewModel.CallService(); }